Copied to clipboard

Flag this post as spam?

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


  • Olly Berry 47 posts 68 karma points
    Nov 03, 2009 @ 11:30
    Olly Berry
    0

    List entire site alphabetically?

    This may seem like an odd request (it certainly does to me, but it's what the client wants!)

    I need to list every page in the site alphabetically for an "A-Z" page (like a sitemap, but less helpful IMO).

    I can't seem to work out how to do this.

    I've got this far:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">

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

    <!-- Change this to root menu node - ie Home -->
    <xsl:variable name="source" select="1046"/>

    <xsl:template match="/">

    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="umbraco.library:GetXmlNodeById($source)"/>
    </xsl:call-template>

    </xsl:template>

    <xsl:template name="drawNodes">
    <xsl:param name="parent"/>
    <xsl:param name="startLevel" select="$parent/@level" />


    <xsl:for-each select="$parent/node [string(data [@alias='umbracoNaviHide']) != '1']">

    <xsl:sort select="@nodeName" order="ascending" />

    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>
    </a>

    <!-- recursive calling of same template for childs -->
    <xsl:if test="count(./descendant::node) > 0">
    <xsl:call-template name="drawNodes">
    <xsl:with-param name="parent" select="."/>
    <xsl:with-param name="startLevel" select="$startLevel"/>
    </xsl:call-template>
    </xsl:if>
    </li>

    </xsl:for-each>



    </xsl:template>

    </xsl:stylesheet>

    ...which lists the entire site, but sorts each set of childs separately - I need one long list sorted alphabetically.

     

    Can anyone help? Many thanks, Olly

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 03, 2009 @ 11:54
    Thomas Höhler
    0

    Try this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [
    <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">

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

    <!-- Change this to root menu node - ie Home -->
    <xsl:variable name="source" select="1046"/>

    <xsl:template match="/">

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/descendant-or-self::node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:sort select="@nodeName" order="ascending" />

    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>

    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

    hth, Thomas

  • Olly Berry 47 posts 68 karma points
    Nov 03, 2009 @ 11:57
    Olly Berry
    0

    Beautiful Thomas, thank you so much. Seems so obvious now I see it!!

Please Sign in or register to post replies

Write your reply to:

Draft