Reputation: 1259
Concrete5 Blocks do not get deleted when they are "removed" because of consistency reasons in the history.
Now I have the following situation: I have a custom block with the database table called btMyCustomBlock.
It looks like this:
|---bID---|---cID---|---someParam---|
Now, when such a block is "removed" and the Page is saved, the database will still maintain the block - which is ok.
BUT: I need a way to detect if my block is used on this page right now. I am looking for something like:
Select a random entry from btMyCustomBlock WHERE entry is used as a block on the page right now.
How can I do that? I found out that the table Blocks has the field bIsActive
but it seems that this does not correlate with what I am looking for, does it?
Upvotes: 1
Views: 110
Reputation: 106
I believe what you are looking for is this
SELECT b.*
FROM btMyCustomBlock b
INNER JOIN CollectionVersionBlocks cvb ON b.bID = cvb.bID
INNER JOIN CollectionVersions cv ON cvb.cvID = cv.cvID
WHERE cv.cvIsApproved = 1
Get all the records that are connected to the currently approved page version.
Upvotes: 1