I can get it to display the first item, January 2011, but then I seem to run into trouble when trying to display the items in 2010. Any idea on how I can display the navigation as above? This is the code I have so far:
<!-- for-each of the "month" nodes -->
<xsl:for-each select="$currentPage/ancestor-or-self::node[@level=3]/node[data[@alias='umbracoNaviHide'] != '1']">
<!-- first sort on the parent's @sortOrder (descending) -->
<xsl:sort select="parent::node/@sortOrder" order="descending" />
<!-- then sort on the nodes @sortOrder (ascending) -->
<xsl:sort select="@sortOrder" order="ascending" />
<li>
<!-- output the month name -->
<xsl:value-of select="@nodeName" />
<!-- output the year -->
<xsl:value-of select="parent::node/@nodeName" />
</li>
</xsl:for-each>
Basically you get all the "month" nodes ... looping through them by the parent's @sortOrder, then its own @sortOrder ... then you can do construct the "month year" text inside the <li> tags.
Quick comment about your original XSLT snippet... if you are using the "umbracoUrlAlias" - make sure you use the correct casing, as its case-sensitive.
Thanks Anders. I had a look at that and try to play around with preceding:: - although it does seem to work when I have January 2011 selected. However when I click on December 2010, I lose January 2011 from the menu.
e.g.
January 2011 (selected) December 2010 November 2010
XSLT navigation help
I have a news section in the following structure:
-Home --News ---2010 ----September ----October ----November ----December ---2011 ----January
I'm trying to write a navigation in XSLT that will display as below:
-January 2011
-December 2010
-November 2010
(etc....)
I can get it to display the first item, January 2011, but then I seem to run into trouble when trying to display the items in 2010. Any idea on how I can display the navigation as above? This is the code I have so far:
<div class="box-shadow"> <div class="box-inner double-height"> <div class="padded"> <h4 class="glint-blue br"> News feed archive </h4> <ul class="secondary-nav"> <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$startDepth]/node [string(data [@alias='umbracoNaviHide']) != '1']"> <xsl:sort select="@sortOrder" order="{$sortBy}" /> <li> <a href="{umbraco.library:NiceUrl(@id)}" title="{./data [@alias='umbracoURLAlias']}"> <xsl:choose> <xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id"> <span> <xsl:value-of select="./data [@alias='umbracoURLAlias']"/> </span> </xsl:when> <xsl:otherwise> <xsl:value-of select="./data [@alias='umbracoURLAlias']"/> </xsl:otherwise> </xsl:choose> </a> </li> </xsl:for-each> </ul> </div> </div> </div>
Thanks,
Bij
Hi Bijesh,
Are you using the old or the new xml schema?
Using the old schema - v4.0.4.2
Okay :)
Try this fantastic XPath visualizer by Chriztian Steinmeier – I think this will solve your problem.
//Anders
Hi Bijesh,
How's about this?
Basically you get all the "month" nodes ... looping through them by the parent's @sortOrder, then its own @sortOrder ... then you can do construct the "month year" text inside the <li> tags.
Cheers, Lee.
Quick comment about your original XSLT snippet... if you are using the "umbracoUrlAlias" - make sure you use the correct casing, as its case-sensitive.
Thanks Anders. I had a look at that and try to play around with preceding:: - although it does seem to work when I have January 2011 selected. However when I click on December 2010, I lose January 2011 from the menu.
e.g.
January 2011 (selected)
December 2010
November 2010
With Dec 2010 selected:
December 2010 (selected)
November 2010
is working on a reply...