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:
    1. $tags[‘horse’] = 22;
    2. $tags[‘cow’] = 12;
    3. $tags[‘chicken’] = 30;
    4. $tags[‘goat’] = 23;
    5. $smarty->assign(‘TagArray’,$tag);
    6. $smarty->display(‘tag-cloud.tpl’);
  3. Then in your template (‘tag-cloud.tpl’ , in this case.) simply use the {tag_cloud} tag, like so:
    1. {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.