Is there a way to determine if a block is being used from a SQL query?

Vote:
 

I have this SQL query:

SELECT
        Content.pkID,
	CL.Name AS [Block Name],
	CL.CreatorName AS [Created By],
	CL.ChangedByName AS [Last Changed By]
FROM
	tblContentType AS [Block]
		INNER JOIN tblContent AS Content ON Content.fkContentTypeID = [Block].pkID
		INNER JOIN tblContentLanguage AS CL on CL.fkContentID = Content.pkID
		--INNER JOIN tblContent AS ContentParent ON ContentParent.pkID = Content.fkParentID
WHERE
	1 = 1
	AND [Block].Name = 'ImageCarouselBlock'
	AND [Content].Deleted = 0

It works, but a lot of these aren't be used on a page. I get the "This item is not used anywhere message. Is there any way to determine if it's being used?

Thanks!

#294062
Jan 03, 2023 17:00
Vote:
 

You should join tables tblContentProperty, tblPropertyDefinition and tblPropertyDefinitionType to tblContentType.

Here is an example of a block on content area in tblContentProperty.  You will need to the block content guid to search,

<div data-classid="36f4349b-8093-492b-b616-05d8964e4c89" data-contentgroup="group_1581718412369" data-contentguid="43212acb-0e1b-4328-9d66-ef138db05380" data-contentname="">{}</div><div data-classid="36f4349b-8093-492b-b616-05d8964e4c89" data-contentgroup="group_1581718412369" data-contentguid="18502083-aaa6-416f-bc9f-84c0d2987396" data-contentname="" data-groups="f9013340-398c-41ee-bba3-de3c2feb4532">{}</div><div data-classid="36f4349b-8093-492b-b616-05d8964e4c89" data-contentgroup="" data-contentguid="4faa829a-7cdb-4b88-9b25-c947d8fa66db" data-contentname="" data-epi-content-display-option="displaymode-half">{}</div><div data-classid="36f4349b-8093-492b-b616-05d8964e4c89" data-contentgroup="" data-contentguid="2a610715-aef8-4890-bd5d-64369f264cf8" data-contentname="" data-epi-content-display-option="displaymode-half">{}</div><div data-classid="36f4349b-8093-492b-b616-05d8964e4c89" data-contentgroup="" data-contentguid="e7ad15e5-ddc1-4040-85e4-3821ae4bbe03" data-contentname="">{}</div>
#294064
Jan 03, 2023 18:05
eperezjr - Jan 03, 2023 20:04
I'm a little confused. I joined those tables to tblContentType like this:

INNER JOIN tblContentProperty AS BlockProperty ON BlockProperty.fkContentID = [Block].pkID
INNER JOIN tblPropertyDefinition AS BlockPropertyDef on BlockPropertyDef.fkContentTypeID = [Block].pkID
INNER JOIN tblPropertyDefinitionType AS BlockPropertyDefType ON BlockPropertyDefType.fkContentTypeGUID = [Block].ContentTypeGUID

[Block] being the tblContentType table. But it produces the same amount of rows if I select distinct. Are the joins correct? Or do I need to check a particular column for data or something else?
Vote:
 

You need to join tblContentProperty the data-contentguid= on LongString column.  When a content area or content reference has a block on it that is how is represented.  

#294108
Jan 04, 2023 1:38
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.