Block ID duplication

Permalink
There is a behaviour I wasn't aware of for a while. It might be useful to know about it when you build your own block..

As mentioned in the documentation every table that is specified in the controller must have a column "bID" which is used to link the block tables to the actual page/block.

When you edit a block, concrete5 creates a new entry in that table. It basically duplicates your data. This is useful because this way, it is possible to "go back in time". You can remove a page version including the block versions.

In my case this behaviour causes a few troubles since I wanted to integrate another system. Means: Two system are updating a few tables and this can be complicated if one system updates the data without informing the other one. I could have added some interfaces between those systems but that's an extra effort.

I then realized that it's quite easy to get the currently published block id. BlockRelations and all the version tables are helpful for that..

I think it would be great if someone with beter english skills good add a note about the behaviour in the documentation (if it's not already there - couldn't find anything)

Remo
 
andrew replied on at Permalink Reply
andrew
This is exactly right. When you edit a block on a particular page, behind the scenes, the system duplicates that block, assigns these duplicated values to a new bID, and then assigns that bID to the new version of the page, then saves your new settings over the old ones.

This way, page versions lets you go back to a previous version of the page as though the block was never changed.

This can cause problems when you're assuming all blocks are going to be unique and approved, however.. For example, when you create a product block, if you edit the block to lower the price, the old bID of your product block is still in the system...and if you have custom scripts that process those blocks they need to know that those old bIDs are no longer valid.

Just another little bit of useful info.
Remo replied on at Permalink Reply
Remo
I didn't want to say it's wrong what you do. I understand it and since I understand it I even like it ;-)

It just wasn't clear at the beginning..