Copied to clipboard

Flag this post as spam?

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


  • Streety 358 posts 567 karma points
    Jul 26, 2011 @ 16:39
    Streety
    0

    Sort node Items into 3 collumns

    I am sure this has already been answered but I can't find a fit that works.

    I have a list of nodes that I want to display into three collums.

    Here is the code:

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


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

    <xsl:param name="currentPage"/>
    <xsl:variable name="rootPage" select="$currentPage/ancestor-or-self::root"/>
    <xsl:variable name="propertyAlias" select="/macro/PropertyAlias"/>

    <xsl:template match="/">

    <xsl:variable name="homepage" select="$currentPage/ancestor-or-self::MainMaster"/>
    <xsl:variable name="nodeIds" select="umbraco.library:Split($homepage/*[name()=$propertyAlias],',')" />

    <ul id="footernav">
    <xsl:for-each select="$nodeIds/value">
    <xsl:variable name="linkNone" select="$rootPage//*[@isDoc][@id = string(current()/.)]"/>
    <xsl:if test="string-length($linkNone/@id)> 0">
    <li>
    <xsl:attribute name="class">
    <xsl:if test="$currentPage/ancestor-or-self::*[@level &gt; 1]/@id = $linkNone/@id">
    <xsl:text>selected</xsl:text>
    </xsl:if>
    <xsl:if test="position() = last()">
    <xsl:text> last</xsl:text>
    </xsl:if>

    </xsl:attribute>

    <xsl:choose>
    <xsl:when test="string-length($linkNone/umbracoUrlAlias) > 0">
    <a class="main-link" href="{$linkNone/umbracoUrlAlias}"><xsl:value-of select="$linkNone/@nodeName"/></a>
    <xsl:value-of select="@nodeName"/>
    </xsl:when>

    <xsl:otherwise>
    <a class="main-link" href="{umbraco.library:NiceUrl($linkNone/@id)}"><xsl:value-of select="$linkNone/@nodeName"/></a>
    <xsl:value-of select="@nodeName"/>
    </xsl:otherwise>

    </xsl:choose>

    </li>
    </xsl:if>
    </xsl:for-each>
    </ul>
    </xsl:template>

    </xsl:stylesheet>

  • Streety 358 posts 567 karma points
    Jul 26, 2011 @ 16:43
    Streety
    0

    Sorry, This forum software has crashed on me again.

     

    Following from last post. I know i need to test the position with mod but can't get the syntax placement correct.

     

    Any help would be gratefully recieved.

  • Richard 146 posts 168 karma points
    Jul 27, 2011 @ 17:52
    Richard
    0

    As you say, when you are writing out the li, you should add a class of say "last" on every third item, which can be done with:

    <li>
    <xsl:if test="position() mod 3 = 0">
    <xsl:attribute name="class">
    <xsl:text>last</xsl:text>
    </xsl:attribute>
    </xsl:if>



    Note that this overwrites any previous class attribute settings, so you would need to change your logic if you want both selected and last as possible settings.

    Richard

  • Streety 358 posts 567 karma points
    Jul 27, 2011 @ 18:38
    Streety
    0

    Thanks for replying.

    I'll look at this again and try and get it going.

  • 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