I have some news articles that are stored by a node "category" and children "year". Using xslt, I am pulling in the parent node of the article, which is the year the article was published, but I would also like to pull in the category of the article as well, but I don't quite know how to go about it. Here is the section my existing xslt that is pulling the parent node of the article.
<div class="featured-articles">
<xsl:for-each select="$featuredArticles">
<div class="listing">
<p class="tag">
<xsl:call-template name="node-name">
<!-- can't do ./parent::* because these nodes are copied and don't have parents -->
<xsl:with-param name="node" select="$currentPage/ancestor-or-self::NewsHome//NewsArticle[@id=current()/@id]/parent::*" />
</xsl:call-template>
</p>
<!-- A template to output the correct name for a given node. Better than copy/pasting this code all over the place -->
<xsl:template name="node-name">
<xsl:param name="node" />
<xsl:if test="string($node) != ''">
<xsl:choose>
<xsl:when test="$node/pageTitle != ''">
<xsl:value-of select="$node/pageTitle"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$node/@nodeName"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
Works great Kim, but I don't understand why we even have to declare the variable "sourceNode" since we never refrence it? Could you help me understand?
Listing Multiple Nested Node Names on Select
Hi,
I have some news articles that are stored by a node "category" and children "year". Using xslt, I am pulling in the parent node of the article, which is the year the article was published, but I would also like to pull in the category of the article as well, but I don't quite know how to go about it. Here is the section my existing xslt that is pulling the parent node of the article.
Hi Steve,
Just to make sure that I understand you correctly. Your sitetree looks like this:
and you want to your xslt to output: Category - Year - Articlename?
Then you could do the following:
First find your articlenode:
Then call you template for the three nodes and put the output in variables to keep your markup clean:
Hop this answers your question :)
-Kim
Works great Kim, but I don't understand why we even have to declare the variable "sourceNode" since we never refrence it? Could you help me understand?
Sorry, I were a bit quick on the copy+paste there :)
Instead of calling:
You could call:
is working on a reply...