Do you want the last published article as per Umbraco or the latest new article that was published? Eg if I have an article that is 2 years old and I for some reason edit it (maybe a spelling mistake) and save and publish, then this will be the last article that's published.
Realistically though I wouldn't know why you'd want that. Assuming it's for the last created article, each node has a createDate property. You can use the XSLT and grab all the documents and order them by date in reverse and then chose the first document. (incidentally, you could possibly use the updateDate to do the other option).
I personally prefer adding a date parameter in the docType so I can set the date manually. Sometimes articles aren't added in the correct order so you can use this field to make sure the latest article is in face the most recent one if for some reason the order of the articles published is not correct.
Get the last posted article
Hi guys and girls
I want to write a piece of xslt code to retrieve the data of the last artilcle that published. Any help is appreciated.
Hi Jeffery,
Do you want the last published article as per Umbraco or the latest new article that was published? Eg if I have an article that is 2 years old and I for some reason edit it (maybe a spelling mistake) and save and publish, then this will be the last article that's published.
Realistically though I wouldn't know why you'd want that. Assuming it's for the last created article, each node has a createDate property. You can use the XSLT and grab all the documents and order them by date in reverse and then chose the first document. (incidentally, you could possibly use the updateDate to do the other option).
I personally prefer adding a date parameter in the docType so I can set the date manually. Sometimes articles aren't added in the correct order so you can use this field to make sure the latest article is in face the most recent one if for some reason the order of the articles published is not correct.
Hi i maybe you can use this the source variable is the homepage and i take only one dokument type:
<xsl:variable name="source" select="1062"/>
<xsl:template match="/">
<ol>
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)/descendant::node [string(data [@alias='umbracoNaviHide']) != '1'][@nodeTypeAlias = 'AOB-Contents Page']">
<xsl:sort select="@createDate" order="descending" />
<xsl:if test="position() < 1">
<li>
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:if>
</xsl:for-each>
</ol>
Br
Martin
Thank you Gary, yes I want to retrieved the last created article.
Thanks Martin, your code works beautifully, I implement it and it is now running on my website.
Cheers guys
is working on a reply...