I was researching building a tag cloud for our blog on this site. I had worked with Saxotech on one many moons ago that utilized a stored procedure in the db and the custom query functionality provided via online tags. You can find a version of this in Saxo docs here: https://docs.saxotech.com/display/Onl/Tag%20Cloud

 

While this solution will work if you have that stored procedure built in your database cluster (we didn’t), you can now use the contentlist tag to create the cloud with much flexibility.

 

Here’s how we did it for Tamberra.com.

 

First, I suggest reading about SOLR Search and Facets/Navigators here if you are shaky on the terminology – https://docs.saxotech.com/display/Onl/Solr%20Search%20Functionality%20in%20Online.

 

We want to create a tag cloud of taxonomy words attached to all our blog posts. Since the contentlist tag can define navigators, we will use the contentlist tag to search for all blog content and use taxonomy as a facet. Note the parameter “FacetFields=Taxonomy”.

 

Now we create the object files that generate the list of taxonomy words. Inside contentlist.pbo, we use the <%facet%> variable to call contentlistFacetList.pbo which will output the list of taxonomy words.

The <%items%> variable should be familiar to all of us. It calls contentListFacetItem.pbo for every taxonomy word returned by the facet list.

 

Inside this file we are doing a few things:

    • We only want to output the taxonomy word if it is a leaf node, and in our taxonomy tree (which is admittedly small right now), we have parent taxonomy nodes we don’t want output. Those are ‘Content’ and ‘Category’. So we wrote object script to exclude those.

 

  • The usual functionality is to create a modifier link to modify the list of content generated by this tag. However, in this case we only want to create a tag cloud and aren’t looking to create the entire faceted search functionality. We have specific rewrites setup, so we create the links per our rewrite rules that will go to a page that lists only the content for that taxonomy word.

 

 

  • Our taxonomy words have ‘_’ for spaces, so we use $r regex to turn those into spaces for output on the site.

 

 

 

Because this is generated using the contentlist tag, you can create a tagcloud per section on your site, or create a list of something other than taxonomy words. It is quite flexible and I was really happy when I learned that the contentlist tag had SOLR facet capabilities built in.

 

Now that you have the tag cloud outputting, you could go even further with some fun jQuery plugins to make your tag cloud look really fun and interesting. Here is a list of 10 libraries: http://www.websanova.com/blog/jquery/10-awesome-jquery-tag-cloud-plugins#.UinnW2Q4XqE

 

So, what do you think? Did you try it? Have questions? Hit us up in the comments below.