Here’s a tag cloud plugin for Smarty.
Download it here:
Here’s how it works:
- Place the ‘function.tag_cloud.php’ file included in the distribution in your smarty plugins directory.
- 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'); - 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.