Delete method of Block Controller not firing on delete
Permalink
The delete method of the block controller apparently only fires if you enter edit mode first, then delete. If you just delete the block on a page it does not fire. In a previous post over a year ago, this was identified as the proper functioning of the block controller.
In the documentation on blocks, it says:
"delete()
This method is responsible for clearing out all information about a block when it's deleted.
"
and is identified as the method to use if your block needs to do additional processing on delete from a page. Unfortunately, if the method only gets called sometimes, then you can't really add additional processing for the block delete that is reliable. The question, then, is how to reliably perform additional processing when a block is deleted without requiring the user to edit the block first?
Assistance with this would be greatly appreciated.
Thank you
In the documentation on blocks, it says:
"delete()
This method is responsible for clearing out all information about a block when it's deleted.
"
and is identified as the method to use if your block needs to do additional processing on delete from a page. Unfortunately, if the method only gets called sometimes, then you can't really add additional processing for the block delete that is reliable. The question, then, is how to reliably perform additional processing when a block is deleted without requiring the user to edit the block first?
Assistance with this would be greatly appreciated.
Thank you
It's a time ago since this thread has been opened, but does anybody have a solution for this?
----- PROBLEM -----
Removing a custom block from the page:
- If in Edit Mode, the concerning row is deleted from it's table.
- If in View Mode, the row isn't deleted from it's table.
C5 Version 5.6.3.1
thx 2 all
----- SOLUTION-----
See below:
http://www.concrete5.org/community/forums/customizing_c5/delete-met...
----- PROBLEM -----
Removing a custom block from the page:
- If in Edit Mode, the concerning row is deleted from it's table.
- If in View Mode, the row isn't deleted from it's table.
C5 Version 5.6.3.1
thx 2 all
----- SOLUTION-----
See below:
http://www.concrete5.org/community/forums/customizing_c5/delete-met...
Are you deleting through some aspect of the c5 user interface, or deleting by calling the api from code?
When deleting from the front end, like a user does.
When deleting the block while in Edit Mode (without publishing), it works, but once it's published & deleted the corresponding row isn't deleted in the blocks db-table.
After googling around, I wrote my own delete method, but it's only a turnaround... which does'nt work. Pls help:
***************
UPDATE
***************
From Andrew Ambler:
"Not a bug. Blocks still store their data so that they can be reinstated in case a previous version of a page gets approved and rolled back to. Block's will only call BlockController::delete() when they no longer need to keep their data around."
See also stackoverflow question & answer:http://stackoverflow.com/questions/22928895/concrete5-block-not-del...
When deleting the block while in Edit Mode (without publishing), it works, but once it's published & deleted the corresponding row isn't deleted in the blocks db-table.
After googling around, I wrote my own delete method, but it's only a turnaround... which does'nt work. Pls help:
public function delete() { $db = Loader::db(); $db->Execute('DELETE FROM ' . $this->btTable . ' WHERE bID = ' . $this->bID); parent::delete(); }
***************
UPDATE
***************
From Andrew Ambler:
"Not a bug. Blocks still store their data so that they can be reinstated in case a previous version of a page gets approved and rolled back to. Block's will only call BlockController::delete() when they no longer need to keep their data around."
See also stackoverflow question & answer:http://stackoverflow.com/questions/22928895/concrete5-block-not-del...
There is some issue with the delete block process, just not sure exactly what yet.