Copied to clipboard

Flag this post as spam?

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


  • Thomas Egebrand Gram 63 posts 138 karma points
    Oct 24, 2011 @ 13:57
    Thomas Egebrand Gram
    0

    UmbracoBlog - BlogLatestComments.xslt not working

    Greetings everyone!

    Some time ago i developed a website in Umbraco 4.7; with an integrated blog via the blog-starter-kit. I went through quite a few bugs in order to get it all working, as it seems the starter-kit wasn't completely up to date on most of the xslt.

    Now, my client would like to add a 'widget' displaying the lastest blog comments in the sidebar. Unfortunately, the BlogLatestComments.xslt doesn't even render in the template, and when saving the default - it throws an "Value was either too large or too small for an Int32."

    I've been searching a bit, and it seems to be a common problem that this script doesn't work for the package. Yet, i have found no solutions to the problem - and i need to get this working properly. I'm thinking it might have something to do with the old xml schema - but to be honest i can't really tell the difference, as i'm not a 'pro' at xslt yet. It may also very well be that the script cant find the comments in the database. But again, i'm clueless at this point.

    This is the xslt for umbBlogLatestComments.xslt:

    <?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:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library BlogLibrary">
      <xsl:output method="html" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
      <xsl:variable name="numberOfComments" select="10"/>
      <xsl:variable name="comments" select="BlogLibrary:GetCommentsForBlog($currentPage/ancestor-or-self::umbBlog/@id)//comment" />
      <xsl:template match="/">
    <xsl:if test="count($comments) &gt; 0">
        <ul>
       <xsl:for-each select="$comments">
            <xsl:sort select="@created" order="descending" />
            <xsl:if test="position() &lt; $numberOfComments +1">
              <li class="comment-item">
                <a href="{umbraco.library:NiceUrl(@nodeid)}#comment-{@id}">
                  <xsl:value-of select="./name"/> on <xsl:value-of select="umbraco.library:GetXmlNodeById(@nodeid)/@nodeName"/>
                </a>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>
    </xsl:if>
      </xsl:template>
    </xsl:stylesheet>

    Any help or directions would be much appreciated solving this problem. If anyone can see the error, or has been through this blog-problem before. Crossing my fingers! :)

    Have a nice day.
    // Thomas

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Oct 24, 2011 @ 22:49
    Chriztian Steinmeier
    0

    Hi Thomas,

    It looks like the package has its own XML format - could you try posting the raw XML output from the GetCommmentsForBlog() call? E.g.:

    <xsl:template match="/">
        <textarea rows="8" cols="40">
            <xsl:copy-of select="BlogLibrary:GetCommentsForBlog($currentPage/ancestor-or-self::umbBlog/@id)" />
        </textarea>
    </xsl:template>

    Note: The macro needs to run on a page of the umbBlog document type, or a descendant thereof, to work.

    /Chriztian

  • Thomas Egebrand Gram 63 posts 138 karma points
    Nov 21, 2011 @ 19:47
    Thomas Egebrand Gram
    0

    Hello Chriztian,

    Appolegies for my very slow reply, been very busy.

    Making a macro with your above code results in this output on the page:

    <textarea cols="40" rows="8"><comments></comments></textarea>

    Now, i also tried visualizing the xslt via the editor:
    Doing this on the umbBlog page or any decendants hereof results in a: "The XSLT didn't generate any output", whereas selecting other document-types results in an error as expected.

    Could it be that the blog-package have saved the comments-incorrectly in some way; so that we're not able to retrieve them?
    You can see this link for the blog by the way: http://www.fuglevang.dk/blog.aspx , check the left col for 'Seneste kommentarer' (latest comments).

    Thanks.
    // Thomas

  • Thomas Egebrand Gram 63 posts 138 karma points
    Dec 21, 2011 @ 18:14
    Thomas Egebrand Gram
    0

    Hello again everyone,

    Anyone who's got a clue on how to fix this? Would love to get this fixed! :-)
    Unfortunately i just can't figure it out myself with my limited time - and this is somewhat of a pet project by now.

    I wish you all a merry christmas!

    // Thomas

Please Sign in or register to post replies

Write your reply to:

Draft