Create a simple TagCloud in PHP

Create a simple TagCloud in PHP

Ok, as for my first post after my away time I’ll be showing you how to make a… Yes you figured it out, a TagCloud.

A TagCloud is as you know a Cloud… with Tags… hum, for some reason I think you already knew that. Anyway, jokes aside, a TagCloud is one of the most powerful visual information display nowadays. It’s not a complex module, by the opposite, it’s very simple.

A normal TagCloud displays all tags, in alphabetic order and the font size varies in according to the amount of times that tag has been found in use. Imagine that you have “hello”, “this”, “is”, “jose”,”blog” as your tags. You would get something like:

hello this is jose blog

You would know that “jose” is the tag with most views (when we say views we can say records in a database).

The installation of the module is very easy and all the required information can be found on the files that i provide.

Extra info:

// This will create a TagCloud with default max font size and minimum font size. The default values can be set on file tagcloud.php in function create_tag_cloud($array,$limit_top_size = 38,$limit_low_size = 18)
$tag_size = create_tag_cloud($tags_array);

Or with specific values

$tag_size = create_tag_cloud($tags_array,40,10);

Max font size will be 40 and minimum font size 10. (these are the max and min values allowed for TagCloud font fluctuation.

And there you go. Just style the code as you like.

PS: Yes, i know what you’re thinking, you can change the code as you please :)

Let me know if you have any issues.

Jul 2009
AUTHOR joseairosa


COMMENTS No Comments

Leave a Reply