Skip Menu |

This queue is for tickets about the HTML-TagCloud CPAN distribution.

Report information
The Basics
Id: 42408
Status: resolved
Priority: 0/
Queue: HTML-TagCloud

People
Owner: Nobody in particular
Requestors: arthas [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Attached is a patch which adds two new parameters for new(): my $cloud = HTML::TagCloud->new( divid => 'myhtmltagclod', classprefix => 'cloudlevel', ); This allows to customize classes of the cloud levels, and especially to specify a different ID for the containing div - thus allowing to put more than one cloud on a page (which, surprisingly, I need to do ;-)). Defaults those parameters are "htmltagclod" and "tagcloud", so this keeps full compatibility with existing code. If patch is accepted I'll be glad to provide docs and tests. Thanks, Michele.
Subject: HTML_TagCloud_params.patch
--- /usr/lib/perl5/vendor_perl/5.10.0/HTML/TagCloud.pm 2009-01-14 11:25:14.000000000 +0100 +++ TagCloud.pm 2009-01-14 17:03:32.000000000 +0100 @@ -9,6 +9,8 @@ counts => {}, urls => {}, levels => 24, + divid => 'htmltagcloud', + classprefix => 'tagcloud', @_ }; bless $self, $class; @@ -23,8 +25,7 @@ sub css { my ($self) = @_; - my $css = q( -#htmltagcloud { + my $css = $self->{divid}.q( { text-align: center; line-height: 1; } @@ -82,8 +83,8 @@ return ""; } elsif ($ntags == 1) { my $tag = $tags[0]; - return qq{<div id="htmltagcloud"><span class="tagcloud1"><a href="}. - $tag->{url}.qq{">}.$tag->{name}.qq{</a></span></div>\n}; + return qq{<div id="}.$self->{divid}.{"><span class="}.$self->{classprefix} + .qq{1"><a href="}.$tag->{url}.qq{">}.$tag->{name}.qq{</a></span></div>\n}; } # warn "min $min - max $max ($factor)"; @@ -92,11 +93,10 @@ my $html = ""; foreach my $tag (@tags) { - $html .= qq{<span class="tagcloud}.$tag->{level}.qq{"><a href="}.$tag->{url}. - qq{">}.$tag->{name}.qq{</a></span>\n}; + $html .= qq{<span class="}.$self->{classprefix}.$tag->{level} + .qq{"><a href="}.$tag->{url}.qq{">}.$tag->{name}.qq{</a></span>\n}; } - $html = qq{<div id="htmltagcloud"> -$html</div>}; + $html = qq{<div id="}.$self->{divid}.qq{">$html</div>}; return $html; }