Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jack Wheeler 10 posts 30 karma points
    Aug 12, 2010 @ 21:21
    Jack Wheeler
    0

    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

  • Jack Wheeler 10 posts 30 karma points
    Aug 12, 2010 @ 21:31
    Jack Wheeler
    0

    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.

  • Jason Prothero 416 posts 1226 karma points c-trib
    Oct 21, 2010 @ 21:59
    Jason Prothero
    0

    Were you able to get this figured out?

  • Jack Wheeler 10 posts 30 karma points
    Oct 22, 2010 @ 19:24
    Jack Wheeler
    0

    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 "&#x00A0;"> ]>
    <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() &lt;= $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() &lt;= $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>

    *******************************************************

  • 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.

Please Sign in or register to post replies