Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of LTjake (4001)

Wednesday October 03, 2007
03:09 PM

HTML::TagCloud::Sortable

[ #34601 ]

HTML tag clouds are pretty popular in a lot of websites. For the project I'm working on right now, i decided to try and mimic del.icio.us's implementation which is sortable by name or by frequency.

HTML::TagCloud is definitely the defacto standard for generating tag clouds in perl. I sorted the data in my SQL query based on the parameter pulled in from the query string and stuffed the data into the cloud. However, no matter what I did the output was always alphabetical.

It turns out that HTML::TagCloud doesn't retain insertion order and automatically sorts your data by tag name.

With Leon's blessing, HTML::TagCloud::Sortable is born. It's API compatible with HTML::TagCloud -- it even passes the same test suite. However, this subclass will also retain the insertion order, allow you to store arbitrary data for tags and sort of any tag field.

It's a little ironic that my main use case for the module was to not sort the tags, but, oh well.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.