|
|
Rank: Devotee
Joined: 5/22/2008 Posts: 68 Location: Auckland, New Zealand
|
How do I go about sorting lists? I've got the blog installed and have created a new date property called newsDate (this was to get around createDates being different to publish dates and updateDate dates). I want to order my posts and the latest news links that I have on the right of the page by this property but I'm not sure how to do it because it's an alias. I tried to add the xsl sort with data[alias="'] etc but that threw me an error. My code for my latest news xslt is below what is the correct syntax for sorting and where should the line go? Lloyd Code:<xsl:variable name="numberOfItems" select="/macro/numberOfItems"/>
<xsl:template match="/"> <div> <h3 class="latestnews">Latest News</h3> <a href="http://ubtest.ecargo.co.nz/data/rss/news.xml" target="_blank" style="float:right; position:relative; top:-27px;"><img src="/media/feed-icon-14x14.png"/></a> <ul> <xsl:for-each select="umbraco.library:GetXmlNodeById(1222)//node [@nodeTypeAlias = 'umbracoBlogPost' and string(data [@alias='umbracoNaviHide']) != '1']"> <xsl:sort select="@createDate" order="descending"/> <xsl:if test="position() <= $numberOfItems"> <li> <small><xsl:value-of select="umbraco.library:LongDate(./data [@alias='newsDate'])"/></small><br/> <a href="{umbraco.library:NiceUrl(@id)}" id="recentpost-{@id}"><xsl:value-of select="@nodeName"/></a><br/></li>
</xsl:if> </xsl:for-each> </ul> </div> </xsl:template>
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,022 Location: Belgium
|
Hi Lloyd, How about this: Code:<xsl:sort select="./data [@alias='newsDateAlias']" order="descending"/> Doesn't throw an error. Didn't actually tried it myself as I don't have such a property atm. Regards, /Dirk
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 601 Location: Bad Homburg, Germany
|
If this is a generic property of your document type then use Code:<xsl:for-each select="YOUR SELECT STATEMENT"> <xsl:sort select="data [@alias = 'THE ALIAS OF YOUR GENERIC PROPERTY']"/>
Also you can add the sort direction into it... hth, Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
Rank: Devotee
Joined: 5/22/2008 Posts: 68 Location: Auckland, New Zealand
|
Thanks guys.
|
|
|
Guest |