Hi, I apologize if this is super obvious, but I couldn't find help by searching.
I would like to list the latest three blog posts from a specific tag on the home page of my site (not the root of the blog, which is a different node). How would I write the xslt to create this feed?
An additional clarification: I'd like to list the title of each post followed by a very short snippet from the post. I will create a property for the blog post document type called "intro" to contain the snippet.
list latest 3 blog posts from a specific tag
Hi, I apologize if this is super obvious, but I couldn't find help by searching.
I would like to list the latest three blog posts from a specific tag on the home page of my site (not the root of the blog, which is a different node). How would I write the xslt to create this feed?
Thanks!
Jack Wheeler
An additional clarification: I'd like to list the title of each post followed by a very short snippet from the post. I will create a property for the blog post document type called "intro" to contain the snippet.
Thanks.
Were you able to get this figured out?
Hi Jason,
Below is the XSLT I ended up with. You'll see that I hard-coded the node of my blog root - GetXmlNodeById(1174)
It's working well.
**************************************
<?xml 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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="numberOfPosts" select="3"/>
<xsl:variable name="blogPosts" select="umbraco.library:GetXmlNodeById(1174)/descendant-or-self::node [@nodeTypeAlias = 'Blog']//node [@nodeTypeAlias = 'BlogPost']" />
<xsl:template match="/">
<h2>Related News and Events:</h2>
<ul class="blog-post-list">
<xsl:for-each select="$blogPosts">
<xsl:sort select="@createDate" order="descending" />
<xsl:if test="position() <= $numberOfPosts">
<xsl:call-template name="showpost">
<xsl:with-param name="post" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</ul>
<!--
<xsl:for-each select="umbraco.library:GetXmlNodeById(1174)/node //node[@nodeTypeAlias = 'BlogPost']">
<xsl:sort select="@createDate" order="descending" />
<xsl:if test="position() = 1">
<h2>Related News and Events:</h2>
</xsl:if>
<xsl:if test="position() <= $numberOfPosts">
<p><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></p>
<xsl:value-of select="@excerpt"/>
</xsl:if>
</xsl:for-each>
-->
</xsl:template>
<xsl:template name="showpost">
<xsl:param name="post"/>
<li class="blog-post-excerpt">
<h4><a href="{umbraco.library:NiceUrl($post/@id)}"><xsl:value-of select="$post/@nodeName"/></a></h4>
<p> <!-- class="entry" -->
<xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml($post/data [@alias = 'excerpt']), 400, '...')" disable-output-escaping="yes"/>
<br /><a href="{umbraco.library:NiceUrl($post/@id)}" title="Permalink to {$post/@nodeName}">Read More...</a> <span class="comment-link"><a href="{umbraco.library:NiceUrl($post/@id)}#respond">Post a comment</a></span></p>
</li>
</xsl:template>
</xsl:stylesheet>
*******************************************************
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.