Copied to clipboard

Flag this post as spam?

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


  • Nikolas van Etten 202 posts 162 karma points
    Mar 17, 2010 @ 11:36
    Nikolas van Etten
    0

    Tags for multiple language site

    I need to display tags for different languages where the tags have all been added in the same property, and I don't want to display any other tags then the ones which are actually being used for the nodes added in that language. Structure somewhat like this:

    no
     - News
      - Article 1 (tags 'tag1, tag2')
      - Article 2 (tags 'tag2, tag3')
    en
     - News
      - Article 1 (tags 'tag4, tag5')
      - Article 2 (tags 'tag5, tag6')

    When opening up no/news.aspx I'd like to display a tag cloud which consists of only tag1, tag2 and tag3 while opening up en/news.aspx should list tag4, tag5 and tag6 in the cloud.

    It's fairly easy getting the tags, but getting the weight is more of a problem if I haven't missed out on an extension in the package?

    Any tips?

  • Nikolas van Etten 202 posts 162 karma points
    Mar 17, 2010 @ 13:11
    Nikolas van Etten
    0

    Looks like this got into the wrong group. Any way to move it?

  • Nikolas van Etten 202 posts 162 karma points
    Mar 17, 2010 @ 15:31
    Nikolas van Etten
    0

    This approach seems to work quite well.

      <!-- All tags [nodeset] -->
      <xsl:variable name="tagsAsElements">
        <xsl:for-each select="$currentPage/descendant-or-self::node [string(data [@alias = 'bodyTags']) != '']">
          <tags for="{@id}">
            <xsl:for-each select="Exslt.ExsltStrings:tokenize(./data [@alias = 'bodyTags'], ',')">
              <tag>
                <xsl:value-of select="normalize-space(.)"/>
              </tag>
            </xsl:for-each>
          </tags>
        </xsl:for-each>
      </xsl:variable>
      <!-- Unique tags [nodeset] -->
      <xsl:key name="tag" match="tag" use="."/>
      <xsl:variable name="uniqueTags">
        <xsl:for-each select="msxml:node-set($tagsAsElements)//tag[generate-id() = generate-id(key('tag', .)[1])]">
          <xsl:sort select="."/>
          <tag count="{count(msxml:node-set($tagsAsElements)/tags[tag = string(current())])}">
            <xsl:value-of select="."/>
          </tag>
        </xsl:for-each>
      </xsl:variable>
      <!-- Tag factor [number] -->
      <xsl:variable name="tagFactor" select="6 div Exslt.ExsltMath:max(msxml:node-set($uniqueTags)//tag/@count)"/>

    I was planning to use the ExsltSets.Distinct extension, but it only gave me an error (also reported here), so needed to use the Muenchian Method approach instead.

    Rest of the code should be fairly similar to the standard tagcloud file included in the blog package etc.

Please Sign in or register to post replies

Write your reply to:

Draft