Hi all,
I figure this must have come up previously but I can't find a forum topic on it - is there an actual hook fired when a block is deleted? I went through the new block hooks for drupal 7 but couldn't find any mention of delete nor does it exist as $op in drupal 6.

I have to delete a bunch of custom variables when a block is deleted so any other ideas/suggestions would help.

Thanks,
Pete

Comments

nevets’s picture

Is the block part of a module or a custom block?

yaworsk’s picture

Custom block.

If it was part of a module, I would probably just write an uninstall function - thoughts?

nevets’s picture

You probably will need to use hook_form_alter() to handle it.

yaworsk’s picture

I have hook_form_alter to create the additional fields in the custom block creation and configure forms, then on the form submit, it sets variables for my fields.

however, how would hook_form_alter help me during the delete process for the custom block?

nevets’s picture

You could use hook_form_alter() to add a submit handler to 'block_custom_block_delete'

jordojuice’s picture

Interesting topic. Might need this some day. Subscribe.

Alan D.’s picture

There is also the module uninstall hook.

/**
 * Implements hook_modules_uninstalled().
 */
function domain_titles_modules_uninstalled($modules) {
  db_delete('domain_title_block')
    ->condition('module', $modules, 'IN')
    ->execute();
}

Then you are into a case by case deletion.

Superfish allows 1 - 50 blocks, you would need to hook into that form submission to remove additional variables. Listening to the entity delete hook for Beans, to remove the Bean blocks, then there are Boxes, Menus, Views (could be a hard one), .....


Alan Davison