Copied to clipboard

Flag this post as spam?

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


  • Anders Dahl Tollestrup 73 posts 52 karma points
    Feb 16, 2011 @ 13:33
    Anders Dahl Tollestrup
    0

    Modifying the blog rss.xslt

    HI

    I'm building my own variant of the umbraco blog with comment nodes instead of holding the comments in seperate tables. My comment DocType alias is BlogComment.

    Everything is working just fine, but I have some throuble with the comment RSS feed.

    The original RSS xslt selection of nodes (part of default template) goes like this:

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

                <xsl:choose>
                  <xsl:when test="$currentPage [name() = 'umbBlogPost']">
                    <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::umbBlog/@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//BlogPost [contains(Exslt.ExsltStrings:lowercase(./tags), Exslt.ExsltStrings:lowercase(umbraco.library:Request('tag')))]">
                      <xsl:sort select="PostDate" order="descending" />
                    </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="$currentPage//BlogPost">
                      <xsl:sort select="PostDate" order="descending" />
                    </xsl:apply-templates>
                  </xsl:otherwise>
                </xsl:choose>

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

    My modification goes like this:

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

                <xsl:choose>
                  <xsl:when test="$currentPage [name() = 'BlogPost']">
                    <xsl:apply-templates select="$currentPage/@id//BlogComment">
                      <xsl:sort select="@createDate" order="descending" />
                    </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="$currentPage/ancestor-or-self::Blog/@id//BlogComment">
                      <xsl:sort select="@createDate" 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//BlogPost [contains(Exslt.ExsltStrings:lowercase(./tags), Exslt.ExsltStrings:lowercase(umbraco.library:Request('tag')))]">
                      <xsl:sort select="PostTime" order="descending" />
                    </xsl:apply-templates>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:apply-templates select="$currentPage//BlogPost">
                      <xsl:sort select="PostTime" order="descending" />
                    </xsl:apply-templates>
                  </xsl:otherwise>
                </xsl:choose>

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

    I have tried to change the  selection "$currentPage/@id/BlogComment" to "$currentPage//BlogComment", but result in a XSLT error when validation the commentrss.aspx feed xml.

    Any help is greatly appriciated :-)

    /Anders

  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 16:07
    Rob Watkins
    0

    What is the error?

  • Anders Dahl Tollestrup 73 posts 52 karma points
    Feb 16, 2011 @ 16:48
    Anders Dahl Tollestrup
    0
  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 17:12
    Rob Watkins
    0

    Well, I don't see anything that should cause a parse error, but I don't get your line: 

    <xsl:apply-templates select="$currentPage/@id//BlogComment">

    It looks like you are attempting to select elements underneath the id attribute - should it not just be $currentPage//BlogComment?

  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 17:13
    Rob Watkins
    0

    God, sorry, I just saw that was what you were trying to change it to, D'OH.

    I can't see why you'd get a parse error on that, it parses fine for me (although I can't run it as I don't have your structure, obviously).

  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 17:18
    Rob Watkins
    0

    If you use the "Visualize XSLT" option from the XSLT editor in Umbraco, does it give you a more useful error?

  • Anders Dahl Tollestrup 73 posts 52 karma points
    Feb 16, 2011 @ 18:49
    Anders Dahl Tollestrup
    0

    Hi Rob

    I have solved the issue. In the following snippet there was a reference to @nodeid, which doesn't exist in the original Umbraco XML and was produced thruogh the blog XSLT extension. I have replaced that @nodeid with my new variable $parentNodeId :-)

    <xsl:template match="BlogComment">
        <xsl:variable name="parentNodeId" select="../@id" />
        
        <xsl:if test="position() &lt;= $RSSNoItems">
          
          <xsl:variable name="link">
            
            <xsl:value-of select="concat(umbraco.library:NiceUrl($parentNodeId),'#comment-',@id)"/>
            
          </xsl:variable>
          
          <xsl:variable name="content">
            <xsl:value-of select="umbraco.library:ReplaceLineBreaks(./comment)"/>
          </xsl:variable>
          
          <item>
            <title>
              Re <xsl:value-of select="umbraco.library:GetXmlNodeById($parentNodeId)/@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(@createDate,'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>

    Everything works just fine now. 

    Anyway, thanks for time on this matter

  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 19:06
    Rob Watkins
    0

    Excellent, glad you solved it!

Please Sign in or register to post replies

Write your reply to:

Draft