Skip to content
raniellyferreira edited this page Apr 24, 2013 · 21 revisions

What is a Tag-Cloud?

A tag-cloud is a collection of text links with varying size (and sometimes color) based on their popularity. Sites such as Flickr, Delicious and Tag-A-Cloud use this concept.

Because alternative?

Dereke Jones created a class like this, say, with the same final functionality. But for leaving for so long I decided to reproduce it and provide it for everyone.

Download Alternative Taggly 1.0

Alternative Taggly 1.0

How to use

Simple example

<?php
$myArray = array (
    array(10, 'PHP', 'http://php.com'),
    array(32, 'MySQL', 'http://mysql.com'),
    array(5, 'CodeIgniter', 'http://codeigniter.com')
);

echo $this->taggly->cloud($myArray);

For more complete customization

<?php
$configs = array(
	'min_font' => 16, //Minimum limit for font size
	'max_font' => 48, //Maximum limit for font size
	'size_type' => 'px', //Type size for setting in the css tags
	'full_tag_open' => '<div id="tag_cloud">', //Start of tag where will all the code
	'full_tag_close' => '</div>', //End of tag
	'item_tag_open' => '<span>', //Start tag for tags
	'item_tag_close' => '</span>',//End of itens tag
	'shuffle' => TRUE, //Random tags
	'link_tag_class' => 'my_css_class', //Class for links tags
	'links_target' => '_top', //Target of links tags
	'find_match' => array(), //Insert here the names of the tags to be highlighted.
	'match_class' => 'match_class' //Class for tags highlighted
);

$this->taggly->load($configs);

$this->taggly->add_tag(array(10, 'PHP', 'http://php.com'));
$this->taggly->add_tag(array(32, 'MySQL', 'http://mysql.com'));
$this->taggly->add_tag(array(5, 'CodeIgniter', 'http://codeigniter.com'));

echo $this->taggly->cloud();

OR

<?php
$configs = array(
	'min_font' => 16, //Minimum limit for font size
	'max_font' => 48, //Maximum limit for font size
	'size_type' => 'px', //Type size for setting in the css tags
	'full_tag_open' => '<div id="tag_cloud">', //Start of tag where will all the code
	'full_tag_close' => '</div>', //End of tag
	'item_tag_open' => '<span>', //Start tag for tags
	'item_tag_close' => '</span>',//End of itens tag
	'shuffle' => TRUE, //Random tags
	'link_tag_class' => 'my_css_class', //Class for links tags
	'links_target' => '_top', //Target of links tags
	'find_match' => array(), //Insert here the names of the tags to be highlighted.
	'match_class' => 'match_class' //Class for tags highlighted
);

$myArray = array (
    array(10, 'PHP', 'http://php.com'),
    array(32, 'MySQL', 'http://mysql.com'),
    array(5, 'CodeIgniter', 'http://codeigniter.com')
);

echo $this->taggly->cloud($myArray,$configs);

##Output

Taggly creates and returns links with defined sizes based on the data given in your array.

An example output:

<div class="tag_cloud">
<span><a class="my_css_class" style="font-size: 16px" target="_top" href="http://php.com">PHP</a></span>
<span><a class="my_css_class" style="font-size: 27px" target="_top" href="http://mysql.com">MySQL</a></span>
<span><a class="my_css_class" style="font-size: 16px" target="_top" href="http://codeigniter.com">CodeIgniter</a></span>
</div>

Reset the configurations to default

<?
$this->taggly->clean();