Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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 " ">]><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 > 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>
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.
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
Thanks for replying.
I'll look at this again and try and get it going.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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 " ">
]>
<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 > 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>
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.
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:
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
Thanks for replying.
I'll look at this again and try and get it going.
is working on a reply...