Cloud Class
MeNeedz's robust Cloud Class supports the following features:
- Adding single arrays or multiple at the same time
- Auto-link tags to given url
- Create tag cloud with font size depending on given count for each tag
- Get plain text list of tags
Create cloud
Creating a tag cloud is pretty simple and requires only a little amount of code.
Here is a basic example demonstrating how you might add tags and create a cloud.
Controller
Setting Cloud Preferences
There are 2 different preferences available to tailor how your cloud creation should work. You can either set them manually as described here, or automatically via preferences stored in your config file, described below:
Preferences are set by passing an array of preference values to the auth initialize function. Here is an example of how you might set some preferences:
$config['min_fon_size'] = 10;
$config['max_fon_size'] = 30;
$this->cloud->initialize($config);
Note: All preferences have default values that will be used if you do not set them.
Setting Cloud Preferences in a Config File
If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the cloud.php, add the $config array in that file. Then save the file at config/cloud.php and it will be used automatically. You will NOT need to use the $this->cloud->initialize() function if you save your preferences in a config file.
Cloud Preferences
The following is a list of all the preferences that can be set when using cloud creation.
Preference | Default Value | Options | Description |
---|---|---|---|
min_font_size | 10 | Numeric value | The minimum font size of the tags in your cloud. |
max_font_size | 30 | Numeric value | The maximum font size of the tags in your cloud |
Cloud Function Reference
$this->cloud->add_tag()
Add a tag to the cloud:
$this->cloud->add_tag('test', 0, 'http://www.google.de');
$this->cloud->add_tag(array(0 => array('name' => 'test', 'count' => 0, 'url' => 'http://www.google.de')));
Returns TRUE on success and FALSE on failure.
$this->cloud->get_plain_list()
Get a plain list of all tags in the cloud:
$this->cloud->get_plain_list(', ', TRUE, FALSE);
Creates a list of all tags seperated by ', ' and linked to the given urls ordered by the sequence they were added. If the third parameter is set to TRUE, then the order is shuffeled. Returns a string.
$this->cloud->get_cloud()
Get the cloud with font size depending on the count for each tag:
$this->cloud->get_cloud(', ', TRUE, FALSE);
Creates a cloud with all tags seperated by ', ' and linked to the given urls ordered by the sequence they were added. If the third parameter is set to TRUE, then the order is shuffeled. Returns a string.