get Content Type using XSLT or velocity

thugsb's Avatar


21 Sep, 2015 07:14 PM

Is there a way, either using XSLT or velocity, to get the name/path/id of the content type of a page?

  1. 1 Posted by Ryan Griffith on 21 Sep, 2015 07:25 PM

    Ryan Griffith's Avatar


    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.

    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?


  2. 2 Posted by thugsb on 21 Sep, 2015 08:22 PM

    thugsb's Avatar

    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):

    #set($dataSet = $currentPage.getStructuredDataNode('data').textValue )
    #set($results = $_.query().byContentType("site://${dataSet}").hasMetadata('title',$currentPage.metadata.title).execute() )
    #set($pageFound = false)
    #foreach($page in $results)
        #if ($ == $
            #set($pageFound = true)
    #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>
  3. thugsb closed this discussion on 21 Sep, 2015 08:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac