I have created the XSLT for a testimonials area that needs to display different testimonials depending on which area of the site you are in. This is filtered by a testCategory. I can only get it working on my homepage and not on any of the other child pages. I have checked the XSLT and it seems to be perfect. The node names are correct as per the XML – Root > Homepage > Testimonials is the path. Heres an example…
I have tried removing the filtering on the alias testCategory and I still get nothing. I think it is a problem with the root path because the hompage filtering is working:
Filtering not working in XSLT
I have created the XSLT for a testimonials area that needs to display different testimonials depending on which area of the site you are in. This is filtered by a testCategory. I can only get it working on my homepage and not on any of the other child pages. I have checked the XSLT and it seems to be perfect. The node names are correct as per the XML – Root > Homepage > Testimonials is the path. Heres an example…
<!--Start filtering for students page-->
<xsl:if test="$currentPage[@nodeName='Students']">
<xsl:for-each select="/root/node[@nodeName='Homepage']/node[@nodeName='Testimonials']/node[string(data [@alias='testCategory']) = 'Student']">
<xsl:sort select="@createDate" order="descending"/>
<h3> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </h3>
<p> <xsl:value-of select="data [@alias = 'testimonialsSnippet']"/><br />
<small>By: <xsl:value-of select="@creatorName"/></small> </p>
</xsl:for-each>
</xsl:if>
<!--End filtering-->
I have tried removing the filtering on the alias testCategory and I still get nothing. I think it is a problem with the root path because the hompage filtering is working:
<!--Start filtering for homepage-->
<xsl:if test="$currentPage[@nodeName='Homepage']">
<xsl:for-each select="$currentPage/node[@nodeName='Testimonials']/node[string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:sort select="@createDate" order="descending"/>
<xsl:if test="position () <= $maxTest">
<h3> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </h3>
<p> <xsl:value-of select="data [@alias = 'testimonialsSnippet']"/><br />
<small>By: <xsl:value-of select="@creatorName"/></small> </p>
</xsl:if>
</xsl:for-each>
</xsl:if>
<!--End filtering-->
Please can anyone help me with this problem?
Many thanks!
Try this... (should work anywhere because of the ancestor-or-self::node going to the top-most node in the tree)
You could probably simplify it more by looking for the docType alias of an individual testimonial (note the '//'). Probably something like:
These were typed into the forum so there's a small chance of a typo... but you should get the idea. Shout if you have problems.
cheers,
doug.
is working on a reply...