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
Hi guys,
I'd like to sort my news items by date. What's the best way to do this?
Here's my code:
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" exclude-result-prefixes="msxml umbraco.library"> <xsl:include href="../xslt/LangLibTurkey.xslt" /> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:variable name="startingContentNode" select="10285"/> <xsl:variable name ="childNodes" select = "$currentPage//*[@isDoc][@id = $startingContentNode]/*[@isDoc]" /> <xsl:if test="$currentPage/@id='10250'"> <div class="newsArticle"> <xsl:apply-templates select = "$childNodes"> xsl:apply-templates> div> xsl:if> xsl:template> <xsl:template match = "*"> <xsl:variable name ="NewsItemDate" select = "NewsItemDate" /> <xsl:value-of select="umbraco.library:FormatDateTime($NewsItemDate, 'd MMMM, yyyy')"/> <div class="articleHeader"> <xsl:value-of select="*[name() = concat('NewsItemTitle',$flang)]" disable-output-escaping="yes" /> div> <div class="articleIntro"> <xsl:value-of select="*[name() = concat('NewsDescription',$flang)]" disable-output-escaping="yes" /> <br/> <xsl:variable name="pdfYes" select="string-length(*[name() = concat('LinkPdf',$flang)])" /> <xsl:choose> <xsl:when test="$pdfYes >0"> <xsl:variable name = "pdfPath" select="umbraco.library:GetMedia(*[name() = concat('LinkPdf',$flang)], 0)/umbracoFile" /> <xsl:choose> <xsl:when test="$flang = '_Tk'"> <a href="{$pdfPath}" target="_blank"> Devamn oku (PDF)...<img src="../../images/RESGroup/buttons/morearrow.gif" alt="more" width="11" height="9" border="0" align="baseline"/> a> xsl:when> <xsl:otherwise> <a href="{$pdfPath}" target="_blank"> Read More (PDF)...<img src="../../images/RESGroup/buttons/morearrow.gif" alt="more" width="11" height="9" border="0" align="baseline"/> a> xsl:otherwise> xsl:choose> <br/> xsl:when> xsl:choose> div> xsl:template>xsl:stylesheet>
Hi Devin,
Inside the 'apply-templates' tag, you can add a 'sort' tag to handle this.
e.g.
<xsl:apply-templates select = "$childNodes"> <xsl:sort select="NewsItemDate" order="descending" data-type="text"/> </xsl:apply-templates>
Cheers, Lee.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XSLT Sort by date
Hi guys,
I'd like to sort my news items by date. What's the best way to do this?
Here's my code:
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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:include href="../xslt/LangLibTurkey.xslt" />
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="startingContentNode" select="10285"/>
<xsl:variable name ="childNodes" select = "$currentPage//*[@isDoc][@id = $startingContentNode]/*[@isDoc]" />
<xsl:if test="$currentPage/@id='10250'">
<div class="newsArticle">
<xsl:apply-templates select = "$childNodes">
xsl:apply-templates>
div>
xsl:if>
xsl:template>
<xsl:template match = "*">
<xsl:variable name ="NewsItemDate" select = "NewsItemDate" />
<xsl:value-of select="umbraco.library:FormatDateTime($NewsItemDate, 'd MMMM, yyyy')"/>
<div class="articleHeader">
<xsl:value-of select="*[name() = concat('NewsItemTitle',$flang)]" disable-output-escaping="yes" />
div>
<div class="articleIntro">
<xsl:value-of select="*[name() = concat('NewsDescription',$flang)]" disable-output-escaping="yes" />
<br/>
<xsl:variable name="pdfYes" select="string-length(*[name() = concat('LinkPdf',$flang)])" />
<xsl:choose>
<xsl:when test="$pdfYes >0">
<xsl:variable name = "pdfPath" select="umbraco.library:GetMedia(*[name() = concat('LinkPdf',$flang)], 0)/umbracoFile" />
<xsl:choose>
<xsl:when test="$flang = '_Tk'">
<a href="{$pdfPath}" target="_blank">
Devamn oku (PDF)...<img src="../../images/RESGroup/buttons/morearrow.gif" alt="more" width="11" height="9" border="0" align="baseline"/>
a>
xsl:when>
<xsl:otherwise>
<a href="{$pdfPath}" target="_blank">
Read More (PDF)...<img src="../../images/RESGroup/buttons/morearrow.gif" alt="more" width="11" height="9" border="0" align="baseline"/>
a>
xsl:otherwise>
xsl:choose>
<br/>
xsl:when>
xsl:choose>
div>
xsl:template>
xsl:stylesheet>
Hi Devin,
Inside the 'apply-templates' tag, you can add a 'sort' tag to handle this.
e.g.
Cheers, Lee.
is working on a reply...