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
hello guys,
i want to create macro that display the most commented posts (the most popular, only the top 5).
i know how to count comments for posts:
<xsl:variable name="numberofcomments" select="count(BlogLibrary:GetCommentsForPost($post/@id)//comment)"/>
i know how to loop on 5 posts:
<ul id="popular-posts"> <xsl:for-each select="$currentPage/ancestor-or-self::node//node [string(data [@alias='umbracoNaviHide']) != '1' and @nodeTypeAlias='BlogPost']"> <xsl:sort select="@createDate" order="descending" /> <xsl:if test="position()<= 5"> <li> <xsl:variable name="text" select="umbraco.library:StripHtml(./data[@alias='bodyHeader'])" /> <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="umbraco.library:TruncateString($text,50,'...')" disable-output-escaping="yes"/></a> </li> </xsl:if> </xsl:for-each></ul>
but i dont know how to connect the dots..
Thanks!
Hi eran,
You should be able to just use the number of comments as the sort option:
<xsl:sort select="count(BlogLibrary:GetCommentsForPost(@id)//comment)" data-type="number" order="descending" />
/Chriztian
EDIT 2013-10-04: Added the data-type attribute which is needed to get the sorting correct.
Thanks, i will check it soon as possible (and will not forget to mark the solution).
Eran.
Can you please share your final solution to this? I am also trying to get this to work on my blog.
@Alexandru I've updated my answer to include the missing data-type attribute
Cheers!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Howto Display most Popular posts?
hello guys,
i want to create macro that display the most commented posts (the most popular, only the top 5).
i know how to count comments for posts:
i know how to loop on 5 posts:
but i dont know how to connect the dots..
Thanks!
Hi eran,
You should be able to just use the number of comments as the sort option:
/Chriztian
EDIT 2013-10-04: Added the data-type attribute which is needed to get the sorting correct.
Thanks, i will check it soon as possible (and will not forget to mark the solution).
Eran.
Can you please share your final solution to this? I am also trying to get this to work on my blog.
@Alexandru I've updated my answer to include the missing data-type attribute
/Chriztian
Cheers!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.