The tag_cloud()
helper will display an array of tags as a cloud, using the hTagCloud microformat syntax for its HTML markup.
Usage
<?php tag_cloud($recordOrTags = null, $link = null, $maxClasses = 9); ?>
Arguments
- recordOrTags - The record or array of tags you wish to display. Can be a item or other record that has tags, or it can be an array of tags. If null,
- link - The URL you wish the tag to link to. Default is null. If null, no link will be created.
- maxClasses - The maximum number of classes to use when creating the cloud.
Examples
The following example will create a cloud of twenty tags, sorted alphabetically, which can then be displayed on the index.php template file in your theme, or anywhere you wish to display it. It uses the get_tags helper to get an array of tags, which is then used as the first argument for the tag_cloud
helper:
<?php $tags = get_tags(array('sort' => 'alpha'), 20); echo tag_cloud($tags, uri('items/browse')); ?>