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:
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.
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 :-)
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')) > 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')) > 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
What is the error?
The error was just "Error parsing XSLT file". See it here: http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Ftollestrup.net%2Fblog%2Fcommentrss.aspx
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?
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).
If you use the "Visualize XSLT" option from the XSLT editor in Umbraco, does it give you a more useful error?
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() <= $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('<![CDATA[ ', $content,']]>')" disable-output-escaping="yes"/>
</content:encoded>
</item>
</xsl:if>
</xsl:template>
Everything works just fine now.
Anyway, thanks for time on this matter
Excellent, glad you solved it!
is working on a reply...