eventless.net

random thoughts and scripts

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About Eventless
  • Vino – wine organizer for Mac

Tag Archives: XML

Sharepoint 2010 Managed Metadata Tag Cloud

Posted on 2011/06/11
11

I’m in the process of reorganizing a Sharepoint 2010 site for our department, and one of the big changes is going from a folder based structure to a flat list of tagged and categorized documents.

In order to create a nice visual way of filtering the list, I’ve implemented a tag cloud using the managed metadata fields in the list. Here it is:

Now, Sharepoint’s built in Tag Cloud Webpart can only access Tags, not Managed Metadata columns. Tags are a no-go since they can’t be shown in list views, and you can’t have multiple sets of metadata. Managed Metadata on the other hand, is perfect for our situation.

So, in order to create the managed metadata tag cloud, I used the brilliant Sharepoint 2010 Managed Metadata WebPart from Brian JC. The web part takes as arguments a list, the column from which you want to display the metadata fields, and an XSL stylesheet to format the contents. And it’s free! (GPL license)

The default stylesheet produces the following output:

Now, in order to get it to display as a tag cloud, replace the default stylesheet with this XSL (swap METADATACOLUMNNAME with the actual column name in your list):

<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' exclude-result-prefixes='msxsl'>
  <xsl:output method='html' indent='yes'/>
  <xsl:template name='terms' match='//termset'>
    <xsl:param name='d'/>
    <div class='termset' style='padding: 10px 0px; text-align: center;'>
      <xsl:variable name='AvgHit'><xsl:value-of select='sum(//term/itemcount) div count(//term[itemcount > 0])'/></xsl:variable>
      <xsl:for-each select='//term[itemcount > 0]'>
        <xsl:sort select='name'/>
        <xsl:element name='span'>
          <xsl:attribute name='style'>
            padding-right: 5px;
            vertical-align: middle;
            padding-left: 5px;
            <xsl:if test='itemcount > $AvgHit'>font-size:1.5em;</xsl:if>
          </xsl:attribute>
          <xsl:element name='a'>
            <xsl:attribute name='href'>?FilterField1=METADATACOLUMNNAME&amp;FilterValue1=<xsl:value-of select='name'/></xsl:attribute>
            <xsl:value-of select='name'/>
          </xsl:element>
        </xsl:element>
        <xsl:if test='position() != last()'>
          <span style="font-size: 90%; color:#ccc; vertical-align:middle;"> | </span>
        </xsl:if>
      </xsl:for-each>
    </div>
  </xsl:template>
</xsl:stylesheet>

What it does:

  • Ignores the metadata structure, listing all tags
  • Removes tags that aren’t used in the list
  • Increases the font size for all tags used in a higher than average number of items (the most popular tags)
  • Adds a link to filter the given list using the chosen tag (Note: The list to be filtered must be on the same page as this web part)
And that’s it! With some knowledge of XSL, it should be easy to adjust this to whatever needs you might have.
Thanks to Brian for a great web part! Any issues or success stories, feel free to post in the comments.
UPDATE: Added a couple of spaces in the delimiter span to fix a problem where the line doesn’t break if there are no tags with spaces in them. Thanks to Christian for the input!
Posted in Random Scripts | Tagged Extensible Stylesheet Language, Metadata, Microsoft SharePoint, Tag cloud, Web part, XML, XSLT | 11 Replies

Tags

AppleScript cocoa Extensible Stylesheet Language Hpricot HTML Metadata Microsoft SharePoint OmniGraffle osx Ruby Sparkle Tag cloud Web part Wine XML XSLT

My Last Tweets

  • Haha. :) RT @madeupstats: In 2011, it is estimated that QR codes were used by 8 people who do not work in marketing, technology or PR. 1 month ago
  • Great blog by @babcockcw about vendor cloud washing: http://t.co/JFOAqyuU So true. 2 months ago
  • Funny and thought provoking blog from our very own @mosesjones - who knew @Capgemini did MDM for Santa? http://t.co/DWJu6wSA 2 months ago
  • Very interesting Bloomberg article about @PalantirTech - would love to learn more about their approach to data mining http://t.co/bZO4Y0sp 2 months ago
  • Has blogged (in Norwegian) about Mobile Business Intelligence for @CapgeminiNorge: http://t.co/zt89HudH 3 months ago
Follow @evenvi

RSS Feed

Theme: Twenty Eleven | Blog at WordPress.com.
Follow

Get every new post delivered to your Inbox.

Powered by WordPress.com