tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/19559-get-content-type-using-xslt-or-velocityCascade CMS: Discussion 2018-10-18T20:37:42Ztag:help-archives.hannonhill.com,2010-02-09:Comment/379871672015-09-21T19:14:40Z2015-09-21T19:14:40Zget Content Type using XSLT or velocity<div><p>Is there a way, either using XSLT or velocity, to get the
name/path/id of the content type of a page?</p></div>thugsbtag:help-archives.hannonhill.com,2010-02-09:Comment/379871672015-09-21T19:25:11Z2015-09-21T19:25:11Zget Content Type using XSLT or velocity<div><p>Hi,</p>
<p>Currently it is only possible to obtain the Page's Data
Definition Path, but not the Content Type. Depending on your use
case, the Query API would allow you to filter pages by a specific
Content Type.</p>
<p>We are looking into adding to the API, so this could be
something to consider. Would you be able to provide your use case
so we can get an idea of how it would be used?</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/379871672015-09-21T20:22:17Z2015-09-21T20:22:17Zget Content Type using XSLT or velocity<div><p>I was trying to test a setting in the DD against the name of the
Content Type (they should match. I solved this by using this code
(the useMetadata is just used to trim down the matches):</p>
<pre>
<code>#set($dataSet = $currentPage.getStructuredDataNode('data').textValue )
#set($results = $_.query().byContentType("site://SarahLawrence.edu/${dataSet}").hasMetadata('title',$currentPage.metadata.title).execute() )
#set($pageFound = false)
#foreach($page in $results)
#if ($page.identifier.id == $currentPage.identifier.id)
#set($pageFound = true)
#end
#end
#if ($pageFound == false)
<div class="bg-danger text-danger text-center">WARNING: The data type may not match the page type. Please inform an administrator.</div>
#end</code>
</pre></div>thugsb