Copied to clipboard

Flag this post as spam?

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


  • Jerker Stigsson 63 posts 122 karma points
    Aug 02, 2013 @ 13:00
    Jerker Stigsson
    0

    Getting all pages containing a list of tags

    I will create a related links function that list pages that contain the same tags as the current page.

    How do I get all or the 10 latest pages or nodes that contain the tags from the current page.

    I would like to use XSLT, since I have very bad experiences with razor. Razor seems to cause performance problems.

    I have found TagsLib. But there is very little documentation on this subject. Does someone have an idea on how to go about this?

  • Jerker Stigsson 63 posts 122 karma points
    Aug 02, 2013 @ 17:46
    Jerker Stigsson
    0

    I found a good start here.

    http://our.umbraco.org/forum/developers/extending-umbraco/3522-Find-related-pages-on-matching-tags

    But the code bellow generates duplicates of pages. If the a node match severel tags it appends to the $news variable bellow. Does anyone know how to remove duplicates?

     
      <xsl:variable name="news-nodes">
        <xsl:for-each select="$tagList/value">
            <xsl:copy-of select="$newsRoot/descendant::*[@isDoc][@nodeTypeAlias = 'NewsItem'][contains(newsTags, current())]" />
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="news" select="msxml:node-set($news-nodes)" />
    
    <xsl:for-each select="$news/* [./@nodeName != $currentPage/@nodeName]">
      <xsl:sort select="newsPublishedDate" order="descending"/>
         <xsl:if test ="((position() &gt; ($page * 5)) and (position() &lt; ((($page + 1) * 5) + 1)))">
          <ul>
        <xsl:call-template name="WritePost">
          <xsl:with-param name="post" select="."></xsl:with-param>          
        </xsl:call-template>
          </ul>
      </xsl:if>
    </xsl:for-each>
    
    
    
Please Sign in or register to post replies

Write your reply to:

Draft