Last active
September 22, 2023 19:37
-
-
Save matdave/1ab01922d3997b4e90195296cbdccf6f to your computer and use it in GitHub Desktop.
MODX count number of times a template is used
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT a.id, a.templatename, COUNT(b.id) as resources FROM modx_site_templates AS a | |
LEFT JOIN modx_site_content AS b ON a.id = b.template AND b.published = 1 AND b.deleted = 0 | |
WHERE b.id IS NOT NULL | |
GROUP BY a.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT a.id, a.type, a.name, COUNT(c.id) FROM modx_site_tmplvars a | |
LEFT JOIN modx_site_tmplvar_contentvalues b ON a.id = b.tmplvarid | |
LEFT JOIN modx_site_content c ON b.contentid = c.id AND c.published = 1 AND c.deleted = 0 | |
WHERE c.id IS NOT NULL | |
GROUP BY a.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment