Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By yaworsk on
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
Is the block part of a module
Is the block part of a module or a custom block?
Custom block
Custom block.
If it was part of a module, I would probably just write an uninstall function - thoughts?
Toronto Website Developer
You probably will need to use
You probably will need to use hook_form_alter() to handle it.
I have hook_form_alter to
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?
Toronto Website Developer
You could use
You could use hook_form_alter() to add a submit handler to 'block_custom_block_delete'
Interesting topic. Might need
Interesting topic. Might need this some day. Subscribe.
There is also the module
There is also the module uninstall hook.
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