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 Umbraco
This is not a casual cry forhelp - I've been stuck for 3 weeks on this apparantly simple issue:
On my homepage I want to list the last 5 child 'news items I have created, regardless of parentage - in date order (recent first)
My structure is:
Home
- News
*New item 1
*New item 2
*New item 3
- Guff
*Guff item 1
*Guff Item 2
etc
I want to list all the sub items in reverse date order, most recent first, regardless of parentage.
<?xml version="1.0" encoding="utf-8"?><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:output method="xml" indent="yes"/> <xsl:param name="currentPage"/> <xsl:variable name="level" select="1"/> <xsl:template match="/"> <xsl:for-each select="$currentPage/*"> <xsl:for-each select="./child::*"> <xsl:sort select="@createDate" order="descending"/> <xsl:if test="@level=3"> <xsl:value-of select ="@nodeName"/> <br></br> <xsl:comment><xsl:value-of select ="content" disable-output-escaping="yes"/></xsl:comment> <br></br> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template></xsl:stylesheet>
This is my best shot so far. It lists the level 3 items, but only in date order per node, rather that date order full stop. I.e my list could be:
Guff item1
News item 1
News Item 2
Guff Item 2
etc,,,
Surely somone has done ths before!!!! I'm close to giving up.
Adam
Hi Adam,
This should be a good starting point - change the two NewsItem alliases to the alias of your News Document Type:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" exclude-result-prefixes="umb" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:param name="currentPage" /> <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" /> <!-- Number of items to show --> <xsl:variable name="maxItems" select="5" /> <xsl:template match="/"> <xsl:for-each select="$siteRoot//NewsItem"> <xsl:sort select="@createDate" data-type="text" order="descending" /> <xsl:if test="position() <= $maxItems"> <xsl:apply-templates select="." /> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template match="NewsItem"> <section class="news"> <header> <h1><xsl:value-of select="@nodeName" /></h1> </header> <xsl:value-of select="content" disable-output-escaping="yes" /> </section> </xsl:template> </xsl:stylesheet>
/Chriztian
Sorry I just deleted my reply, havent refresh my page and didnt know Chriztian did reply.
Thanks for the reply Chriztian - that worked a treat with very little tweaking.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Display the top 5 child nodes
Hi Umbraco
This is not a casual cry forhelp - I've been stuck for 3 weeks on this apparantly simple issue:
On my homepage I want to list the last 5 child 'news items I have created, regardless of parentage - in date order (recent first)
My structure is:
Home
- News
*New item 1
*New item 2
*New item 3
- Guff
*Guff item 1
*Guff Item 2
etc
I want to list all the sub items in reverse date order, most recent first, regardless of parentage.
This is my best shot so far. It lists the level 3 items, but only in date order per node, rather that date order full stop. I.e my list could be:
Guff item1
News item 1
News Item 2
Guff Item 2
etc,,,
Surely somone has done ths before!!!! I'm close to giving up.
Adam
Hi Adam,
This should be a good starting point - change the two NewsItem alliases to the alias of your News Document Type:
/Chriztian
Sorry I just deleted my reply, havent refresh my page and didnt know Chriztian did reply.
Thanks for the reply Chriztian - that worked a treat with very little tweaking.
is working on a reply...