Zend_Tag_Cloud is the rendering part of
Zend_Tag. By default it comes with a set of HTML
decorators, which allow you to create tag clouds for a website, but
also supplies you with two abstract classes to create your own
decorators, to create tag clouds in PDF documents for example.
You can instantiate and configure Zend_Tag_Cloud either
programatically or completely via an array or an instance of
Zend_Config. The available options are:
cloudDecorator: defines the decorator for the cloud. Can either be the name of the class which should be loaded by the pluginloader, an instance of
Zend_Tag_Cloud_Decorator_Cloudor an array containing the string 'decorator' and optionally an array 'options', which will be passed to the decorators constructor.tagDecorator: defines the decorator for individual tags. This can either be the name of the class which should be loaded by the pluginloader, an instance of
Zend_Tag_Cloud_Decorator_Tagor an array containing the string 'decorator' and optionally an array 'options', which will be passed to the decorators constructor.pluginLoader: a different plugin loader to use. Must be an instance of
Zend_Loader_PluginLoader_Interface.prefixPath: prefix paths to add to the plugin loader. Must be an array containing the keys prefix and path or multiple arrays containing the keys prefix and path. Invalid elements will be skipped.
itemList: a different item list to use. Must be an instance of
Zend_Tag_ItemList.tags: a list of tags to assign to the cloud. Each tag must either implement
Zend_Tag_Taggableor be an array which can be used to instantiateZend_Tag_Item.
Example 936. Using Zend_Tag_Cloud
This example illustrates a basic example of how to create a tag cloud, add multiple tags to it and finally render it.
<?php
// Create the cloud and assign static tags to it
$cloud = new Zend_Tag_Cloud(array(
'tags' => array(
array('title' => 'Code', 'weight' => 50,
'params' => array('url' => '/tag/code')),
array('title' => 'Zend Framework', 'weight' => 1,
'params' => array('url' => '/tag/zend-framework')),
array('title' => 'PHP', 'weight' => 5,
'params' => array('url' => '/tag/php')),
)
));
// Render the cloud
echo $cloud;
This will output the tag cloud with the three tags, spread with the default font-sizes.




