Deleting a block's record upon block deletion

Permalink
The BlockController's delete() method works when you first add a block in edit mode then delete it before saving any changes.

However, if you add a block, publish the page, go back into edit mode then delete the block the record still remains in the block's table.

What am I missing to ensure the when the block is deleted that it's record is always removed?

Thanks!

beebs93
 
Steevb replied on at Permalink Reply
Steevb
Hi,
Sorry, are you asking about database removal?

If you remove a package from the dashboard-functionality-edit (pick a add on) and tick 'Yes, remove the package's directory from of the installation directory.'

Then click 'Unistall Package' that should remove all trace?

If I got this, let me know.

Thanks

Steev
beebs93 replied on at Permalink Reply
beebs93
Thanks for the the reply, Steev.

I meant deleting an individual block from a page and wanting said block's entry in its btTable to be deleted as well.

Example:

- I make a block myself that uses a table called "btMyBlock" (not part of a package), install it and add it to an area on a page.

- I publish the changes and now the block is on my site.

- I re-enter edit mode, delete the block, then publish the changes.

Doing this does NOT remove the record from the btMyBlock table.

However, if you add a block then delete it before publishing the changes then it is removed. Once you publish changes, though, the record is there forever.

I'd like to have block records in their block-type tables to be removed whenever one of its blocks are deleted.

I've tried overwriting the BlockController's delete() method, but it doesn't fire when you a delete a block that has been published.
beebs93 replied on at Permalink Best Answer Reply
beebs93
Ah, nevermind. After looking into the Block's model I realized you can't be deleting block records once published since different versions of pages still have the block.
imran replied on at Permalink Reply
Hi, beebs, i have the same problem and yet not fully understand the issue, actually i want to delete a block and expecting that block will also delete its record but unfortunately not working,...

Any help will be appreciated. Thanks
beebs93 replied on at Permalink Reply
beebs93
My understanding is that once you first add a block to an area, but have not yet published the changes, said block will not be recorded in any versions of the page you're editing.

As soon as you add a block AND publish the changes then you've just created a new version of that page. Until you delete that version from the "Versions" menu, the block record is there to stay. Reason being that should you ever want to revert to an earlier version of a page then any blocks present will still be there.

Wait for a senior dev to call bulls**t on me just in case I'm missing something.

Hope that helps :)