How to get the doc type from Multi Node Tree picker
Hello,
I'm using the Multi Node Tree picker to get different types of content and display it on a page. These contents are boxes like Teasers, Quotes etc. I would like to loop through each node and check it's doc type. This will help me to style it appropriately. I have some sample code below but couldn't find a way to get the doc type so all the boxes look the same:
<!-- First we check that the Multi-node Tree Picker has any nodeId values --> <xsl:if test="$currentPage/teasersList/MultiNodePicker/nodeId"> <!-- Loop through each of the nodeId values --> <xsl:for-each select="$currentPage/teasersList/MultiNodePicker/nodeId">
<!-- Since we only have the nodeId value, we need to get the actual content node using umbraco.library's GetXmlNodeById method --> <!-- If you prefer to use pure XPath, then used this: "$currentPage/ancestor-or-self::*[@isDoc and @level = 1]/descendant-or-self::*[@isDoc and @id = current()]" --> <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(.)" /> <div style="border:1px solid #000;width:200px; margin-bottom:10px;"> <xsl:choose> <xsl:when test="$node/teaserHeader !=''"> <div><xsl:value-of select="$node/teaserHeader"/></div> <xsl:if test="$node/teaserSummary !=''"> <div style="padding-top:10px;"><xsl:value-of select="$node/teaserSummary"/></div> </xsl:if> </xsl:when> <xsl:otherwise> <div><xsl:value-of select="$node/teaserSummary"/></div> </xsl:otherwise> </xsl:choose> <xsl:if test="$node/quoteText !=''"> <blockquote><xsl:value-of select="$node/quoteText" disable-output-escaping="yes"/></blockquote> </xsl:if> </div>
</xsl:for-each>
</xsl:if>
So basically while looping through each of the nodeId values I need to get the doc type of each node so that I can give it a different look. The doc types for my 2 boxes are Teaserbox and Quotebox
Hope someone can help me out with some code sample.
Thanks for the reply but I don't understand how to use that as i'm quite new to xslt. What is "local-name" or is that where I put the name of the doc type alias? So assuming my doctype is "Teaserbox" how do I create an if statement surrounding my styled div?
How to get the doc type from Multi Node Tree picker
So basically while looping through each of the nodeId values I need to get the doc type of each node so that I can give it a different look. The doc types for my 2 boxes are Teaserbox and Quotebox
Hope someone can help me out with some code sample.
Thanks,
Wasim
sorry for the post above not showing properly. This forum has an error when trying to edit a post.
Hey,
This will get you the doc type
Hope it helps!
Rich
Hi Rich,
Thanks for the reply but I don't understand how to use that as i'm quite new to xslt. What is "local-name" or is that where I put the name of the doc type alias? So assuming my doctype is "Teaserbox" how do I create an if statement surrounding my styled div?
Hi again,
Just tested. Got it:
<xsl:if test="local-name($node) = 'Teaserbox'">
<div>My custom box</div>
</xsl:if>
Thanks
is working on a reply...