Copied to clipboard

Flag this post as spam?

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


  • Bijesh Tank 192 posts 420 karma points
    Jan 20, 2011 @ 14:11
    Bijesh Tank
    0

    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

  • Anders Stentebjerg 58 posts 234 karma points
    Jan 20, 2011 @ 15:54
    Anders Stentebjerg
    1

    Hi Bijesh,

    Are you using the old or the new xml schema? 

  • Bijesh Tank 192 posts 420 karma points
    Jan 20, 2011 @ 16:02
    Bijesh Tank
    0

    Using the old schema - v4.0.4.2

  • Anders Stentebjerg 58 posts 234 karma points
    Jan 20, 2011 @ 16:09
    Anders Stentebjerg
    0

    Okay :)

    Try this fantastic XPath visualizer by Chriztian Steinmeier – I think this will solve your problem.

    //Anders

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jan 20, 2011 @ 16:14
    Lee Kelleher
    1

    Hi Bijesh,

    How's about this?

    <!-- 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.

    Cheers, Lee.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jan 20, 2011 @ 16:16
    Lee Kelleher
    1

    Quick comment about your original XSLT snippet... if you are using the "umbracoUrlAlias" - make sure you use the correct casing, as its case-sensitive.

  • Bijesh Tank 192 posts 420 karma points
    Jan 20, 2011 @ 16:17
    Bijesh Tank
    0

    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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies