Copied to clipboard

Flag this post as spam?

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


  • Max Mumford 266 posts 293 karma points
    Jan 06, 2011 @ 17:17
    Max Mumford
    0

    alphabetical sort not working

    Hi all,

    I have a script that lists all the child elements of a page and sorts them by date. Instead, I want them to be sorted by pageTitle attribute however, once changing the select attribute in the sort code and refreshing the page, the list remains the same. here is my code:

    <xsl:for-each select="$currentPage/node[@nodeTypeAlias='FAQItem']">

    <xsl:sort select="pageTitle" order="ascending" data-type="text" />

    <xsl:if test="position() &lt;= $numberOfItems">

    <li>

    <xsl:attribute name="class">bullet</xsl:attribute>

    <a href="{umbraco.library:NiceUrl(@id)}">

    <xsl:value-of select="@nodeName"/>

    </a>

    </li>

    </xsl:if>

    </xsl:for-each>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 06, 2011 @ 17:35
    Lee Kelleher
    0

    Hi Max,

    Which version of Umbraco are you using? or are you using the new or legacy XML schema?

    Based on your loop, it looks like your using the legacy XML schema (from before Umbraco v4.5).

    Try this XSLT:

    <xsl:for-each select="$currentPage/node[@nodeTypeAlias='FAQItem']">
        <xsl:sort select="data[@alias='pageTitle']" order="ascending" data-type="text" />
        <xsl:sort select="@nodeName" order="ascending" data-type="text" />
        <xsl:if test="position() &lt;= $numberOfItems">
            <li class="bullet">
                <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName"/>
                </a>
            </li>
        </xsl:if>
    </xsl:for-each>

    I added the 2nd <xsl:sort> tag in there for any nodes that didn't have a "pageTitle" property to sort on ... feel free to remove it! ;-)

    Cheers, Lee.

     

  • Max Mumford 266 posts 293 karma points
    Jan 06, 2011 @ 17:42
    Max Mumford
    0

    Hi,

    Thanks for your reply. That did it! all works now.

    I am using Umbraco 4.5.1 and this is something that is confusing me; I thought 4.5.1 used the new schema, however the legacy schema is what I am using for XSLT on the site and it is working, despite the fact that I cannot find any reference to the useLegacySchema attribute in any *.config file.... Is this normal?!

    Thanks,
    Max.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 06, 2011 @ 17:46
    Lee Kelleher
    0

    Hi Max,

    If you upgraded to v4.5.x from an earlier version, then the legacy XML schema is enabled by default.

    The setting is in "~/config/umbracoSettings.config" if you wanted to change it ... but remember that you would need to republish all your content pages and modify all your XSLT accordingly.

    Cheers, Lee.

  • Max Mumford 266 posts 293 karma points
    Jan 06, 2011 @ 17:51
    Max Mumford
    0

    Ah I see, okay thanks very much.

  • Max Mumford 266 posts 293 karma points
    Jan 07, 2011 @ 17:25
    Max Mumford
    0

    incidentally, is it possible that a very old xslt cache meant that some old schema xslt would still work alongside some new, new schema xslt?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 07, 2011 @ 17:27
    Lee Kelleher
    1

    I did find that when I switched an upgraded install over from legacy to new XML schema, the umbraco.config kept all the old nodes in there.

    Only when I deleted the umbraco.config and "Republished entire site" (from right-clicking the root Content node) - that it only store the new XML schema nodes.

    Cheers, Lee.

  • Max Mumford 266 posts 293 karma points
    Jan 07, 2011 @ 17:43
    Max Mumford
    0

    That would explain it :)

    Thanks.

    Max,

Please Sign in or register to post replies

Write your reply to:

Draft