Copied to clipboard

Flag this post as spam?

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


  • mark 8 posts 29 karma points
    Nov 30, 2011 @ 14:38
    mark
    0

    Displaying top x runway blog posts on root home page

    I recently upgraded from Umbraco 3.5 to 4 and am again lost on how to make my blog posts display on the home page.

    I borrowed the XSLT below from another user on these forums. I confirmed the Macro was created. I am not sure what data source I need to add to make the blogs work. I created a document type called newsSource because that is what I used with my old Umbraco installs and bound it to the "news" section of my site (the blog install). I am sure there is somthing simple below that I am missing in one of the select's, but I don't know what it is.

    My page renders "Latest blog posts" and that is all, so the macro is running (which is progress for me).

    Any help would be much appreciated!

    Mark

    <?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="numberOfItems">
        <xsl:choose>
          <xsl:when test="/macro/numberOfItems != ''">
            <xsl:value-of select="/macro/numberOfItems"/>
          </xsl:when>
          <xsl:otherwise>5</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:variable name="excerptLength">
        <xsl:choose>
          <xsl:when test="string(/macro/excerptLength) != ''">
            <xsl:value-of select="/macro/excerptLength"/>
          </xsl:when>
          <xsl:otherwise>100</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:template match="/">

        <h3>Latest blog posts</h3>
        <ul class="summaryList" id="blogSummary">
          <xsl:for-each select="$currentPage/umbBlog/umbBlogPost [@isDoc and string(umbracoNaviHide) != '1']">
            <xsl:if test="position() &lt;= $numberOfItems">
              <li>
                <h4>
                  <href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName"/>
                  </a>
                </h4>
                <p>
                  <xsl:choose>
                    <xsl:when test="string($excerptLength) != '0'">
                      <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(bodyText), number($excerptLength), '...')" disable-output-escaping="yes"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="bodyText" disable-output-escaping="yes"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </p>
                <small>
                  <xsl:value-of select="umbraco.library:ShortDate(PostDate)"/>
                </small>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>

      </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft