I am trying to clean up some of our unneeded templates, is there a query I can run to find the dependencies on a specific template?
Precursor…
On the general tab of a template in workbench, there are choices for Publish: Always, Default, Never. I’m going to assume that the templates you wish to eliminate are already marked “Never,” which should be the case with your snippet templates. Otherwise, you’re dealing with a page template, and you’re publishing that template (if it’s marked always or default) which implies it is used.
Assuming you have an Oracle backend, this query will give you a count (including zero) of templates used within the context of a slot.
SELECT pt.template_id,
pt.name,
COUNT(por.variant_id) as USAGE
FROM psx_template pt
LEFT JOIN psx_objectrelationship por
ON por.variant_id =pt.template_id
WHERE por.slot_id IS NOT NULL
GROUP BY pt.template_id,
pt.name
ORDER BY COUNT(por.variant_id) ASC;
That’s just off the cuff.
More in response to your question…
SELECT por.owner_id,
por.dependent_id,
pt.template_id,
pt.name AS TEMPLATE_NAME
FROM psx_template pt,
psx_objectrelationship por
WHERE por.slot_id IS NOT NULL
AND por.variant_id =pt.template_id
AND pt.name =‘vtSnBio’;
The owner_id is the contentid of the content item containing the slot
The dependent_id is the contentid included in the slot
the template_id and template_name identify the template being used for the dependent in the slot.