Copied to clipboard

Flag this post as spam?

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


  • Lloyd 15 posts 35 karma points
    Oct 26, 2011 @ 00:17
    Lloyd
    0

    tagsLib issues

    I'm using umbraco Blog for umbraco 4.5.2. Here is my BlogPosts code:

    <?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:umbracoTags.library="urn:umbracoTags.library"
    exclude-result-prefixes="msxml umbraco.library umbracoTags.library">

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

    <xsl:param name="currentPage"/>

    <!-- Don't change this but create a 'number' element in your -->
    <!-- macro with the alias of 'numberOfItems' -->
    <xsl:variable name="numberOfItems" select="/macro/numberOfItems"/>

    <xsl:template match="/">
    <!-- The fun starts here -->
    <xsl:choose>
    <xsl:when test="umbraco.library:Request('filterBy') != ''">
    <xsl:variable name="filter" select="umbraco.library:Request('filterBy')"/>
    <xsl:variable name="nodes" select="umbracoTags.library:getContentsWithTag($filter)/root/* [@isDoc]"/>
    <div class="post"><hr/><h4 style="margin:0.5em 0px 0.8em;">Posts with tag: <xsl:value-of select="umbraco.library:Request('filterBy')"/></h4>
    <p>There are <xsl:value-of select="count($nodes)"/> posts with this tag</p>
    <a href="?filterBy={$filter}&amp;sortBy=date">Sort by date</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?filterBy={$filter}&amp;sortBy=title">Sort by title</a>
    </div>
    <hr/>
    <xsl:variable name="sorter" select="umbraco.library:Request('sortBy')"/>
    <xsl:choose>
    <xsl:when test="$sorter = 'date'">
    <xsl:call-template name="sortByDate">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:when test="$sorter = 'title'">
    <xsl:call-template name="sortByTitle">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:when test="$sorter = 'comments'">
    <xsl:call-template name="sortByComments">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="sortByDate">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>

    </xsl:when>

    <xsl:otherwise>
    <xsl:for-each select="$currentPage/descendant-or-self::node [@nodeTypeAlias = 'umbracoBlogPost' and string(umbracoNaviHide) != '1']">
    <xsl:sort select="newsDate" order="descending"/>
    <xsl:if test="position() &lt;= $numberOfItems">
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:if>
    </xsl:for-each>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="sortByDate">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="newsDate" order="descending"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="sortByTitle">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="@nodeName" order="ascending" data-type="text"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="sortByComments">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="count(./* [@isDoc])" order="descending" data-type="number"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>

    <xsl:template name="listpost">
    <xsl:param name="node"/>
    <div class="post">
    <h3 id="post-{$node/@id}">
    <a href="{umbraco.library:NiceUrl($node/@id)}" rel="bookmark" title="Permalink for {$node/@nodeName}">
    <xsl:value-of select="$node/@nodeName"/>
    </a>
    </h3>
    <small>
    <xsl:value-of select="umbraco.library:LongDate($node/newsDate)"/> by <xsl:value-of select="$node/@writerName"/>
    </small>

    <div class="entry">
    <xsl:choose>
    <xsl:when test="./bodyText != ''">
    <xsl:value-of select="umbraco.library:RenderMacroContent($node/bodyText, $node/@id)" disable-output-escaping="yes"/>

    </xsl:when>
    <xsl:otherwise>
    &nbsp;
    </xsl:otherwise>
    </xsl:choose>

    </div>

    <div>
    <xsl:if test="count(umbracoTags.library:getTagsFromNode($node/@id)/tags/tag) &gt; 0">
    <span style="float:left; height:16px; veritcal-align:text-top;">Categories:&nbsp;</span><ul style="float:left;"><xsl:for-each select="umbracoTags.library:getTagsFromNode($node/@id)/tags/tag"><li style="display:inline;"><a href="?filterby={current()}"><xsl:value-of select="current()"/></a>&nbsp;</li></xsl:for-each></ul>
    &nbsp;&nbsp;|&nbsp;&nbsp;</xsl:if>

    <a href="{umbraco.library:NiceUrl($node/@id)}/#comments"><xsl:value-of select="count($node/* [@isDoc][string(commentSpam) != '1'])"/> Comment(s) &#187;</a></div>

    </div>
    <hr class="dark" /></xsl:template>

    </xsl:stylesheet>

    My XsltExtensions looks like this:

    <?xml version="1.0" encoding="utf-8" ?> 
    <XsltExtensions>
    <ext assembly="/umbraco.editorControls" type="umbraco.editorControls.tags.library" alias="tagsLib">
    </ext>
    <ext assembly="/Umlaut.Umb.Blog" type="Umlaut.Umb.Blog.BlogLibrary" alias="BlogLibrary">
    </ext>
    </XsltExtensions>

    On the BlogPosts page when I'm trying to filter by Tag I'm getting this error:

    Cannot find the script or external object that implements prefix 'urn:umbracoTags.library'.

    I've taken a look at the BlogArchives xslt and it's using a different namespace (I think) for the TagsLib, so I copied this in at the top of my xslt and made amendments to the types in the document to change from umbracoTags.library to tagsLib. This saves ok but when trying to view the page I'm getting this error:

    Extension object 'urn:tagsLib' does not contain a matching 'getContentsWithTag' method that has 1 parameter(s).

    I've tried searching for some documentation on the tagsLib to check what methods are available but can't find anything. Where am I going wrong? I'm trying to list out content related to a tag specified in the filter variable and at the base run a count and show content based on the tags in the node.

  • Lloyd 15 posts 35 karma points
    Oct 26, 2011 @ 00:33
    Lloyd
    0

    Can't seem to edit my post (I'm receiving an error). What I intended to edit was to post the code that showed the implementation of tagsLib in my BlogPosts 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:tagsLib="urn:tagsLib"
    exclude-result-prefixes="msxml umbraco.library tagsLib">
     
    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <!-- Don't change this but create a 'number' element in your -->
    <!-- macro with the alias of 'numberOfItems' -->
    <xsl:variable name="numberOfItems" select="/macro/numberOfItems"/>

    <xsl:template match="/">
    <!-- The fun starts here -->
    <xsl:choose>
    <xsl:when test="umbraco.library:Request('filterBy') != ''">
    <xsl:variable name="filter" select="umbraco.library:Request('filterBy')"/>
    <xsl:variable name="nodes" select="tagsLib:getContentsWithTag($filter)/root/* [@isDoc]"/>
    <div class="post"><hr/><h4 style="margin:0.5em 0px 0.8em;">Posts with tag: <xsl:value-of select="umbraco.library:Request('filterBy')"/></h4>
    <p>There are <xsl:value-of select="count($nodes)"/> posts with this tag</p>
    <a href="?filterBy={$filter}&amp;sortBy=date">Sort by date</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?filterBy={$filter}&amp;sortBy=title">Sort by title</a>
    </div>
    <hr/>
    <xsl:variable name="sorter" select="umbraco.library:Request('sortBy')"/>
    <xsl:choose>
    <xsl:when test="$sorter = 'date'">
    <xsl:call-template name="sortByDate">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:when test="$sorter = 'title'">
    <xsl:call-template name="sortByTitle">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:when test="$sorter = 'comments'">
    <xsl:call-template name="sortByComments">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:call-template name="sortByDate">
    <xsl:with-param name="nodes" select="$nodes"/>
    </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>

    </xsl:when>

    <xsl:otherwise>
    <xsl:for-each select="$currentPage/descendant-or-self::node [@nodeTypeAlias = 'umbracoBlogPost' and string(umbracoNaviHide) != '1']">
    <xsl:sort select="newsDate" order="descending"/>
    <xsl:if test="position() &lt;= $numberOfItems">
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:if>
    </xsl:for-each>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="sortByDate">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="newsDate" order="descending"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="sortByTitle">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="@nodeName" order="ascending" data-type="text"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="sortByComments">
    <xsl:param name="nodes"/>
    <xsl:for-each select="$nodes">
    <xsl:sort select="count(./* [@isDoc])" order="descending" data-type="number"/>
    <xsl:call-template name="listpost">
    <xsl:with-param name="node" select="."/>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>

    <xsl:template name="listpost">
    <xsl:param name="node"/>
    <div class="post">
    <h3 id="post-{$node/@id}">
    <a href="{umbraco.library:NiceUrl($node/@id)}" rel="bookmark" title="Permalink for {$node/@nodeName}">
    <xsl:value-of select="$node/@nodeName"/>
    </a>
    </h3>
    <small>
    <xsl:value-of select="umbraco.library:LongDate($node/newsDate)"/> by <xsl:value-of select="$node/@writerName"/>
    </small>

    <div class="entry">
    <xsl:choose>
    <xsl:when test="./bodyText != ''">
    <xsl:value-of select="umbraco.library:RenderMacroContent($node/bodyText, $node/@id)" disable-output-escaping="yes"/>

    </xsl:when>
    <xsl:otherwise>
    &nbsp;
    </xsl:otherwise>
    </xsl:choose>

    </div>

    <div>
    <xsl:if test="count(tagsLib:getTagsFromNode($node/@id)/tags/tag) &gt; 0">
    <span style="float:left; height:16px; veritcal-align:text-top;">Categories:&nbsp;</span><ul style="float:left;"><xsl:for-each select="tagsLib:getTagsFromNode($node/@id)/tags/tag"><li style="display:inline;"><a href="?filterby={current()}"><xsl:value-of select="current()"/></a>&nbsp;</li></xsl:for-each></ul>
    &nbsp;&nbsp;|&nbsp;&nbsp;</xsl:if>

    <a href="{umbraco.library:NiceUrl($node/@id)}/#comments"><xsl:value-of select="count($node/* [@isDoc][string(commentSpam) != '1'])"/> Comment(s) &#187;</a></div>

    </div>
    <hr class="dark" /></xsl:template>

    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft