Copied to clipboard

Flag this post as spam?

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


  • Jesper Pedersen 12 posts 32 karma points
    May 08, 2011 @ 12:15
    Jesper Pedersen
    0

    Rss feed in blog4umbraco is empty

    Hello

    I'm using Blog4Umbraco but the rss feed is always empty.

    I'm using the standart xslt file BlogRss.xslt, but it dosn't show any posts.

    Here is my structure:

     

    And the code:

    <?xml version="1.0" encoding="UTF-8"?>
    <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:rssdatehelper="urn:rssdatehelper"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
    xmlns:BlogLibrary="urn:BlogLibrary"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltStrings BlogLibrary">


      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>

      <xsl:variable name="iscommentfeed" select="//macro/iscommentfeed" />

      <!-- Update these variables to modify the feed -->
      <xsl:variable name="RSSNoItems" select="string('10')"/>
      <xsl:variable name="RSSTitle">
        <xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'Blog']/data [@alias = 'blogName']"/>
        <xsl:if test="$iscommentfeed = '1'">
          <xsl:text> comment feed</xsl:text>
          <xsl:if test="$currentPage/@nodeTypeAlias = 'BlogPost'">
            <xsl:value-of select="concat(' for ', $currentPage/@nodeName)"/>
          </xsl:if>
        </xsl:if>
        <xsl:if test="string-length(umbraco.library:Request('tag')) &gt; 0">
          <xsl:value-of select="concat(' for tag ', umbraco.library:Request('tag'))"/>
        </xsl:if>
      </xsl:variable>
      

      <xsl:variable name="SiteURL" select="concat('http://',string(umbraco.library:RequestServerVariables('HTTP_HOST')))"/>
      <xsl:variable name="RSSDescription" select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'Blog']/data [@alias = 'blogDescription']"/>

      <!-- This gets all news and events and orders by updateDate to use for the pubDate in RSS feed -->
      <xsl:variable name="pubDate">
        <xsl:choose>
          <xsl:when test="$iscommentfeed = '1'">
            <xsl:for-each select="$currentPage//node [@alias = 'BlogPostComment']">
              <xsl:sort select="@createDate" data-type="text" order="descending" />
              <xsl:if test="position() = 1">
                <xsl:value-of select="@updateDate" />
              </xsl:if>
            </xsl:for-each>
          </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="string-length(umbraco.library:Request('tag')) &gt; 0">
                <xsl:for-each select="$currentPage//node [@alias = 'BlogPost' and contains(Exslt.ExsltStrings:lowercase(./data [@alias='tags']), Exslt.ExsltStrings:lowercase(umbraco.library:Request('tag')))]">
                  <xsl:sort select="@createDate" data-type="text" order="descending" />
                  <xsl:if test="position() = 1">
                    <xsl:value-of select="@updateDate" />
                  </xsl:if>
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="$currentPage//node [@alias = 'BlogPost']">
                  <xsl:sort select="@createDate" data-type="text" order="descending" />
                  <xsl:if test="position() = 1">
                    <xsl:value-of select="@updateDate" />
                  </xsl:if>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <xsl:template match="/">


        <!-- change the mimetype for the current page to xml -->
        <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>

        <xsl:text disable-output-escaping="yes">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</xsl:text>
        <rss version="2.0"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
    >

          <channel>
            <title>
              <xsl:value-of select="$RSSTitle"/>
            </title>
            <link>
              <xsl:value-of select="$SiteURL"/>
            </link>
            <pubDate>
              <xsl:value-of select="$pubDate"/>
            </pubDate>
            <generator>umbraco</generator>
            <description>
              <xsl:value-of select="$RSSDescription"/>
            </description>
            <language>da</language>

            <xsl:choose>
              <xsl:when test="$iscommentfeed = '1'">

                <xsl:choose>
                  <xsl:when test="$currentPage/@nodeTypeAlias = 'BlogPost'">
                    <xsl:apply-templates select="BlogLibrary:GetCommentsForPost($currentPage/@id)//comment">
                      <xsl:sort select="@created" order="descending" />
                    </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="BlogLibrary:GetCommentsForBlog($currentPage/ancestor-or-self::node [@nodeTypeAlias = 'Blog']/@id)//comment">
                      <xsl:sort select="@created" order="descending" />
                    </xsl:apply-templates>
                  </xsl:otherwise>
                </xsl:choose>


              </xsl:when>
              <xsl:otherwise>

                <xsl:choose>
                  <xsl:when test="string-length(umbraco.library:Request('tag')) &gt; 0">
                    <xsl:apply-templates select="$currentPage//node [@nodeTypeAlias = 'BlogPost' and contains(Exslt.ExsltStrings:lowercase(./data [@alias='tags']), Exslt.ExsltStrings:lowercase(umbraco.library:Request('tag')))]">
                      <xsl:sort select="@createDate" order="descending" />
                    </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
                    
                    <xsl:apply-templates select="$currentPage//node [@nodeTypeAlias = 'BlogPost']">
                      <xsl:sort select="@createDate" order="descending" />
                    </xsl:apply-templates>
                  </xsl:otherwise>
                </xsl:choose>

              </xsl:otherwise>
            </xsl:choose>

          </channel>
        </rss>

      </xsl:template>

      <xsl:template match="comment">
        <xsl:if test="position() &lt;= $RSSNoItems">
          <xsl:variable name="link">
            <xsl:value-of select="concat(umbraco.library:NiceUrl(@nodeid),'#comment-',@id)"/>
          </xsl:variable>
          <xsl:variable name="content">
            <xsl:value-of select="umbraco.library:ReplaceLineBreaks(./message)"/>
          </xsl:variable>
          <item>
            <title>
              Re <xsl:value-of select="umbraco.library:GetXmlNodeById(@nodeid)/@nodeName"/> by <xsl:value-of select="./name"/>
            </title>
            <link>
              <xsl:value-of select="$SiteURL"/>
              <xsl:value-of select="$link"/>
            </link>
            <pubDate>
              <xsl:value-of select="umbraco.library:FormatDateTime(@created,'r')" />
            </pubDate>
            <guid>
              <xsl:value-of select="$SiteURL"/>
              <xsl:value-of select="$link"/>
            </guid>
            <content:encoded>
              <xsl:value-of select="concat('&lt;![CDATA[ ', $content,']]&gt;')" disable-output-escaping="yes"/>
            </content:encoded>
          </item>
        </xsl:if>
      </xsl:template>

      <xsl:template match="node">
        <xsl:if test="position() &lt;= $RSSNoItems">
          <xsl:variable name="link">
            <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
          </xsl:variable>
          <xsl:variable name="content">
            <xsl:value-of select="./data [@alias='bodyText']"/>
          </xsl:variable>
          <item>
            <title>
              <xsl:value-of select="@nodeName"/>
            </title>
            <link>
              <xsl:value-of select="$SiteURL"/>
              <xsl:value-of select="$link"/>
            </link>
            <pubDate>
              <xsl:value-of select="umbraco.library:FormatDateTime(@createDate,'r')" />
            </pubDate>
            <guid>
              <xsl:value-of select="$SiteURL"/>
              <xsl:value-of select="$link"/>
            </guid>
            <description>
              <xsl:value-of select="concat('&lt;![CDATA[ ', $content,']]&gt;')" disable-output-escaping="yes"/>
            </description>
          </item>
        </xsl:if>
      </xsl:template>

    </xsl:stylesheet>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 08, 2011 @ 12:22
    Jan Skovgaard
    0

    Hi Jesper

    What version of Umbraco are you using B4U on?

    At first sight it seems to me that the first XSLT file has not been converted to use the new XML schema, which is probably why your RSS feed is empty because it's trying to match another schema structure than is in fact being used in the umbraco.config file.

    To convert the file from the old schema to the new schema you can use this converter: http://blackpoint.dk/umbraco-workbench/tools/convert-xml-schema-to-45-.aspx

    Hope this helps.

    /Jan

  • Jesper Pedersen 12 posts 32 karma points
    May 08, 2011 @ 15:33
    Jesper Pedersen
    0

    Hi..

    I'm using Umbraco 4.5.2.

    Tried the converting tool, and it made som changes, but still no output... :(

  • Jesper Pedersen 12 posts 32 karma points
    May 08, 2011 @ 16:09
    Jesper Pedersen
    0

    I got it to work by changing:

    $currentPage//node [@nodeTypeAlias = 'BlogPost']

    $currentPage//node [@alias = 'BlogPost']

    $currentPage/@nodeTypeAlias = 'BlogPost'

    to:

    $currentPage/ancestor-or-self::Blog//BlogPost

Please Sign in or register to post replies

Write your reply to:

Draft