I am using Umbraco V4.7. I have a macro that loops through some content (NewsArticle), extracting a property called "newsArticleContent".
This works 100% and all articles display but what i'm actually working on at the moment is to have a summary of the top 3 articles in the order of which they were created. So if i have Article 1, Article 2, Article 3, Article 4 and Article 5, i only want to show Article 5, Article 4 and Article 3, since they are the latest ones created.
What i'm struggling with is sorting them and having a counter or index inside so that it only goes through the top 3. XSLT and macros are quite a challenge for me at the moment.
What i also need to do is display only the first 20 words of the article's rich text editor property newsArticleContent, with a link at the end "[read more]" pointing the user to the actual article, but if i can just get to extract the top 3, i would be greatful.
This is great, amazing in fact, it works like a charm! Both of you helped me a lot. I don't suppose i can mark 2 answers as the solution... I'll mark Fuji's answer as right for showing me how to use the TruncateString function as well, it helps with the summary of the news.
Loop to extract only top few pages
Good day,
I am using Umbraco V4.7. I have a macro that loops through some content (NewsArticle), extracting a property called "newsArticleContent".
This works 100% and all articles display but what i'm actually working on at the moment is to have a summary of the top 3 articles in the order of which they were created. So if i have Article 1, Article 2, Article 3, Article 4 and Article 5, i only want to show Article 5, Article 4 and Article 3, since they are the latest ones created.
This is the xslt i have at the moment:
<xsl:param name="currentPage"/>
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
<xsl:template match="/">
<xsl:for-each select="$siteRoot/NewsSection/NewsArticle[not(umbracoNaviHide = 1)]">
<xsl:value-of select="newsArticleContent" disable-output-escaping="yes" />
</xsl:for-each>
</xsl:template>
What i'm struggling with is sorting them and having a counter or index inside so that it only goes through the top 3. XSLT and macros are quite a challenge for me at the moment.
What i also need to do is display only the first 20 words of the article's rich text editor property newsArticleContent, with a link at the end "[read more]" pointing the user to the actual article, but if i can just get to extract the top 3, i would be greatful.
Any help would be highly appreciated.
Thank you.
Regards,
Matei
Hi Matei,
What you could do is in your docType add a field ArticlePublished and choose DatePicker.
I hope this helps
Hi Matei,
I will try to help you the best I can. I have not tried it myself, but hope it can help you further.
Maybe you could try something like
I have found inspiration for my reply through this post, so maybe this can help you.
http://our.umbraco.org/forum/developers/xslt/5815-Sorting-output-by-date
Hope at least this may help to help you solve your issues
/Dennis
Opps....Slight error here
I guess you meant
:-)
Cheers,
Michael
Hey guys,
This is great, amazing in fact, it works like a charm! Both of you helped me a lot. I don't suppose i can mark 2 answers as the solution... I'll mark Fuji's answer as right for showing me how to use the TruncateString function as well, it helps with the summary of the news.
Thank you both!
Hi Matei glad if you got it working.
//fuji
Hi Matei,
That´s alright with me :-). Glad that I could help you in some way.
/Dennis
is working on a reply...