get Content Type using XSLT or velocity

thugsb's Avatar

thugsb

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

    Hi,

    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?

    Thanks!

  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://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
    
  3. thugsb closed this discussion on 21 Sep, 2015 08:22 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? 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

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM