Up
Using pbs:contentlist to generate a dynamic tag cloud - Tamberra
Here at Tamberra, we see ourselves as professional digital problem solvers. We love a good mystery and that is what your project might be at this stage… a mystery. Who, what, where, when, why – these are all questions that we can help you answer.
Tampa, Web Development, Web Developers, Web Applications, Tampa Bay, Programmers, Newspaper Web Developer
5972
post-template-default,single,single-post,postid-5972,single-format-standard,do-etfw,ajax_fade,page_not_loaded,,vertical_menu_enabled,side_area_uncovered_from_content,qode-theme-ver-7.5,wpb-js-composer js-comp-ver-5.1,vc_responsive

Using pbs:contentlist to generate a dynamic tag cloud

tag cloud

06 Sep Using pbs:contentlist to generate a dynamic tag cloud

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.

 

Stacey Jenkins

Stacey Jenkins

Stacey has 15+ years of project implementations under her belt. From very large to very small, she has managed, analyzed, built, and tested systems and then trained teams how to use them. Specifics are on her linkedin, but at the end of the day, Stacey enjoys building things that give real value to the business at hand. She loves this stuff.
Stacey Jenkins