Hi Everyone, im new to the forum, i like umbraco a lot, and im trying to use it in every single proyect that i have
Now, i have a big question about what is the best way to aproach sort functions using xslt
i have a front page where all the info for birthdays in my intranet is showed with name, month and day, but i just can find a way to sort the output of the macro in my frontpage.
<!-- update this variable on how deep your site map should be --> <xsl:variable name="maxLevelForSitemap" select="6"/> <xsl:template match="/"> <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/> </xsl:call-template> </xsl:template> <xsl:template name="drawNodes"> <xsl:param name="parent"/> <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)"> <xsl:for-each select="$parent/*[@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]"> <!--<xsl:value-of select="name(./*[@isDoc])"/><br/>--> <xsl:sort select="birthdayEY" order="descending"/> <xsl:if test="@template = 1165"> <!-- Fix to all folders with template id --> <xsl:variable name="DateToday" select="umbraco.library:CurrentDate()"/> <xsl:if test="umbraco.library:FormatDateTime($DateToday, 'MMMM') = umbraco.library:FormatDateTime(birthdayEY, 'MMMM') ">
Thanks a lot for help works perfect, i just change the descending for ascending, and now i have it sorted as i want too, have a nice day!, thanks a lot again!
Can't Sort Content Using Xslt
Hi Everyone, im new to the forum, i like umbraco a lot, and im trying to use it in every single proyect that i have
Now, i have a big question about what is the best way to aproach sort functions using xslt
i have a front page where all the info for birthdays in my intranet is showed with name, month and day, but i just can find a way to sort the output of the macro in my frontpage.
this is the code of the xlst.
<?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="no"/>
<xsl:param name="currentPage"/>
<!-- update this variable on how deep your site map should be -->
<xsl:variable name="maxLevelForSitemap" select="6"/>
<xsl:template match="/">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<xsl:for-each select="$parent/*[@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]">
<!--<xsl:value-of select="name(./*[@isDoc])"/><br/>-->
<xsl:sort select="birthdayEY" order="descending"/>
<xsl:if test="@template = 1165"> <!-- Fix to all folders with template id -->
<xsl:variable name="DateToday" select="umbraco.library:CurrentDate()"/>
<xsl:if test="umbraco.library:FormatDateTime($DateToday, 'MMMM') = umbraco.library:FormatDateTime(birthdayEY, 'MMMM') ">
<tr>
<td>
<span style="color:#747170"> <xsl:value-of select="nameEY"/></span>
</td>
<td>
<xsl:value-of select="umbraco.library:FormatDateTime(birthdayEY, 'MMMM d')"/>
</td>
</tr>
</xsl:if>
</xsl:if>
<xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
and this is a picture of the output content in the front page
any ideas? thanks a lot for help i really need it!
I'd recommend the AutoSort package... it will autosort the nodes so they are ready prior to render. You can sort by node names or any property.
http://our.umbraco.org/projects/backoffice-extensions/auto-sort
i am assuming the the birthdays are stored as a complete date and are therefore ordered as date of birth by year, month, day.
i don't think that the autosort will work for this unless the day, month and year are stored seperately.
you presumably need to sort by day within a given month
i'll have a think
This shoudl work for you:
<xsl:sort select="umbraco.library:FormatDateTime(birthdayEY, 'mm dd')" order="descending"/>
Thanks a lot for help works perfect, i just change the descending for ascending, and now i have it sorted as i want too, have a nice day!, thanks a lot again!
Your very welcome... glad it worked for you.
is working on a reply...