‘Tag Cloud’ plugin for Smarty

May 4th, 2007 by Jaybill McCarthy

Here’s a tag cloud plugin for Smarty.

Download it here:

tag_cloud.zip

Here’s how it works:

  1. Place the ‘function.tag_cloud.php’ file included in the distribution in your smarty plugins directory.
  2. In your php script, do something like this:
    $tags['horse'] = 22;
    $tags['cow'] = 12;
    $tags['chicken'] = 30;
    $tags['goat'] = 23;
    $smarty->assign('TagArray',$tag);
    $smarty->display('tag-cloud.tpl');
  3. Then in your template (’tag-cloud.tpl’ , in this case.) simply use the {tag_cloud} tag, like so:
    {tag_cloud tags=$TagArray base_url='search.php?q='}

The script will take the following parameters:

  • tags (required) - the tags and the totals for each tag - associative array
  • base_url (required) - the base url to which the tag will be appended - string
  • min_font_size (optional) - minimum font size (default 12) - integer
  • max_font_size (optional) - maximum font size (default 30) - integer
  • id (optional) - css id (default ‘tag_cloud’) - string
  • class (optional) - css class (default ‘tag_cloud’) - string

I got the basic code for this from this really great tutorial over at scriptplayground.


Posted in Updates |

Leave a Reply