Template Audit


Lists live/working templates in alpha order and which live/working html pages are using them.

Very basic, can probably be configured to list more helpful information.


${esc.hash}${esc.hash} template audit
${esc.hash}${esc.hash} uses direct database queries to list each extant templates
${esc.hash}${esc.hash} and which live html pages are using it.
${esc.hash}${esc.hash} Jonathan Laughlin <>
${esc.hash}${esc.hash} Nov 14, 2011

${esc.hash}getSQLResults("SELECT inode,title FROM template WHERE live = 1 AND working = 1 AND deleted = 0 ORDER BY title asc")
${esc.hash}set(${esc.dollar}templateInfo = ${esc.dollar}results)

${esc.hash}foreach(${esc.dollar}t in ${esc.dollar}templateInfo)
 ${esc.hash}set(${esc.dollar}templateInode = ${esc.dollar}t.inode)
 ${esc.hash}getSQLResults("SELECT identifier FROM inode WHERE inode = '${esc.dollar}templateInode'")
 ${esc.hash}foreach(${esc.dollar}i in ${esc.dollar}results)
  ${esc.hash}if(${esc.dollar}velocityCount == 1)
   ${esc.hash}set(${esc.dollar}templateIdentifier = ${esc.dollar}i.identifier)
 ${esc.hash}getSQLResults("select * from htmlpage where live = 1 and working = 1 and deleted = 0 and inode in (select child from tree where parent = '${esc.dollar}templateIdentifier') order by title asc")
 ${esc.hash}foreach(${esc.dollar}a in ${esc.dollar}results)

Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor