Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Bradsted Bodenhoff 27 posts 47 karma points
    Feb 24, 2010 @ 11:53
    Peter Bradsted Bodenhoff
    0

    Retrieving template/documenttype in xslt

    Hi

    Is it possible to retrieve the selected template and/or documenttype for a page??

    something like umbraco.library:GetXmlNodeById($source)/self::node/$template

  • Petr Snobelt 923 posts 1535 karma points
    Feb 24, 2010 @ 11:55
    Petr Snobelt
    0

    documenttypeis in something like nodeTypeAlias attribute

  • Tommy Poulsen 514 posts 708 karma points
    Feb 24, 2010 @ 11:57
    Tommy Poulsen
    1

    Hi Peter, content nodes contains "nodeType" and "template" attributes directly on the node.

    >Tommy

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 24, 2010 @ 12:41
    Dirk De Grave
    0

    not sure if the template can be found in the xml, if it's possible, you'd use /@template instead of /$template (from xslt that is). And even then you'd only get the id of the template.

    Any idea why you'd need the template from xslt?

    Cheers,

    /Dirk

  • Kim Andersen 1447 posts 2196 karma points MVP
    Feb 24, 2010 @ 12:59
    Kim Andersen
    1

    Sometimes I have used the templateID in my XSLT to determine which template, an array of selected nodes, had. In this way I could do different stuff to the choosen nodes, depending on what templateID was used.

    But this could also be achieved by getting the @nodeTypeAlias of the nodes, if i wanted to make the selection by document type. But sometimes the document types can have several different templates. In this way things could easily be messed up.

    But back to your question Peter.

    You can achieve the templateID by using something like this:

    <xsl:value-of select="$currentPage/@template" />

    And you can get the document type ALIAS by doing something like this:

    <xsl:value-of select="$currentPage/@nodeTypeAlias" />

    Instead of $currentPage, you can of cource use your own source if you want to.

    I hope this makes sense to you...

    /Kim A

  • Petr Snobelt 923 posts 1535 karma points
    Feb 25, 2010 @ 09:35
    Petr Snobelt
    0

    BTW: I think xslt should not be depend on template, which calling it.

    Dependancy on documentType is sometimes ok, but you should rather use parameter and modify templates to use this parameter.

    Petr

Please Sign in or register to post replies

Write your reply to:

Draft