how do you get the template ID, I looked in CMSTemplate and took the node ID. The query seems to return a list of all the content codes associated with the doctype associated with the template. I could do with a filter that only brought back nodes that had a specific template applied.
To get the TemplateID, you can hover over the template in the back office and you'll see the ID in the browser status line.
Alternativily you can look in the cmsTemplate table (the templateId is actually the nodeId).
Here's an updated script to get the content nodes using template found by the template alias:
DECLARE @templateId AS int SELECT @templateId = nodeId FROM cmsTemplate WHERE alias='Template Alias'
SELECT C.path AS 'Path', C.level AS 'Level', C.id AS 'Node Id', C.text AS 'Text', A.alias AS 'docType Alias' FROM cmsContentType A LEFT OUTER JOIN cmsContent B ON A.nodeId = B.contentType INNER JOIN umbracoNode C ON B.nodeId = C.id WHERE A.nodeId IN ( SELECT contentTypeNodeId FROM cmsDocumentType A INNER JOIN cmsContentType B ON A.contentTypeNodeId = B.nodeId WHERE templateNodeid = @templateId ) ORDER BY text ASC
Arh, just re-read your post, and yes it'll return all nodes that could potentially use the supplied template. I'll have a go at updating the SQL so it'll only return content nodes with the template defined...
TSQL to get Content Nodes associated with a template
Has anyone got a TSQL query that will get a list of nodes associated to a template, please?
Hi Brendan,
Does this forum post help ? There's SQL to get content nodes from a template Id.
HTH,
Hendy
Perfect, couldn't find a related post, thanks Hendy.
Hi Hendy,
how do you get the template ID, I looked in CMSTemplate and took the node ID. The query seems to return a list of all the content codes associated with the doctype associated with the template. I could do with a filter that only brought back nodes that had a specific template applied.
Any ideas?
Thanks,
Brendan
Hi Brendan,
To get the TemplateID, you can hover over the template in the back office and you'll see the ID in the browser status line.
Alternativily you can look in the cmsTemplate table (the templateId is actually the nodeId).
Here's an updated script to get the content nodes using template found by the template alias:
HTH,
Hendy
Arh, just re-read your post, and yes it'll return all nodes that could potentially use the supplied template. I'll have a go at updating the SQL so it'll only return content nodes with the template defined...
Hi Brendan,
How about this:
HTH,
Hendy
Perfect Hendy thanks a million for the help.
is working on a reply...