Copied to clipboard

Flag this post as spam?

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

  • Ian Pettman 25 posts 53 karma points
    Sep 03, 2013 @ 14:48
    Ian Pettman

    Xslt changing the order of menu items

    I am in the process of editing a website (and am fairly new to this) and one thing that I need to achieve is to change the order that the blog posts display in the drop down menu. At the moment they go in ascending order, with the oldest post being at the top. But I need to change this so that the newest posts displays at the top, on firstly the 'Year' sub-menu, and then the 'Month' sub-menu.

    If anyone could help point me in the right direction it would be a great help.

    The blog is using ublogsy and I am using umbraco 4.11

    Here is a rough example of how the content tree is structured.


            About us

    This is the XSLT file that is generating the menu.

    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE xsl:stylesheet [
            <!ENTITY nbsp "&#x0A;">
      exclude-result-prefixes="msxml umbraco.library">

            <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

            <xsl:param name="currentPage" />
            <xsl:variable name="level" select="1" />
            <xsl:variable name="navRoot" select="$currentPage/ancestor-or-self::*[@level = $level][not(umbracoNaviHide = 1)]" />
            <xsl:variable name="navRootItems" select="$navRoot/*[@isDoc][not(umbracoNaviHide = 1)]" />

            <xsl:template match="/">
                <a title="Show navigation" href="#nav">Show navigation</a>
                <a title="Hide navigation" href="#">Hide navigation</a>      

                <div id="navlogo"><a title="HOME" href="/home.aspx">  
                <span style="position:absolute;width:100%;height:100%;top:0;left: 0;"></span>

                      <ul class="clearfix">
                          <xsl:if test="$currentPage/@nodeName = 'Home'"><xsl:attribute name="class">current</xsl:attribute></xsl:if>
                          <a href="/">Home</a>

                      <xsl:if test="$navRootItems">

                          <xsl:apply-templates select="$navRootItems" />

                        <div id="menuspace"/>


            <xsl:template match="*[@isDoc]">

                <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">current</xsl:attribute></xsl:if>
                  <xsl:attribute name="href">
                    <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
                    <xsl:when test="@level = 4 and (self::uBlogsyFolderMonth | self::umbracoBlogDateFolder | self::DateFolder)">
                      <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'MMMM')" />
                      <xsl:apply-templates select="@nodeName" />
                <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)][not((self::uBlogsyFolderMonth | self::umbracoBlogDateFolder | self::DateFolder)[@level = 5])]">
                    <xsl:apply-templates select="*[@isDoc][not(umbracoNaviHide = 1)][not((self::uBlogsyFolderMonth | self::umbracoBlogDateFolder | self::DateFolder)[@level = 5])]" />

            <xsl:template match="@nodeName[string-length() &gt; 25]">
              <xsl:attribute name="title">
                <xsl:value-of select="." />
              <xsl:value-of select="concat(substring(., 1, 24), '&#8230;')" />


  • Kasper Dyrvig 246 posts 379 karma points
    Sep 16, 2013 @ 19:10
    Kasper Dyrvig

    Hi Ian,

    I'm not that experienced with ublogsy. BUT you can try experimenting with this:

    <xsl:apply-templates select="$navRootItems">
    <xsl:sort select="@createDate" order="descending"/>

    Hope this can help you...

Please Sign in or register to post replies

Write your reply to: