1HTML::TagCloud(3)     User Contributed Perl Documentation    HTML::TagCloud(3)
2
3
4

NAME

6       HTML::TagCloud - Generate An HTML Tag Cloud
7

SYNOPSIS

9         # A cloud with tags that link to other web pages.
10         my $cloud = HTML::TagCloud->new;
11         $cloud->add($tag1, $url1, $count1);
12         $cloud->add($tag2, $url2, $count2);
13         $cloud->add($tag3, $url3, $count3);
14         my $html = $cloud->html_and_css(50);
15
16         # A cloud with tags that do not link to other web pages.
17         my $cloud = HTML::TagCloud->new;
18         $cloud->add_static($tag1, $count1);
19         $cloud->add_static($tag2, $count2);
20         $cloud->add_static($tag3, $count3);
21         my $html = $cloud->html_and_css(50);
22
23         # A cloud that is comprised of tags in multiple categories.
24         my $cloud = HTML::TagCloud->new;
25         $cloud->add($tag1, $url1, $count1, $category1);
26         $cloud->add($tag2, $url2, $count2, $category2);
27         $cloud->add($tag3, $url3, $count3, $category3);
28         my $html = $cloud->html_and_css(50);
29
30         # The same cloud without tags that link to other web pages.
31         my $cloud = HTML::TagCloud->new;
32         $cloud->add_static($tag1, $count1, $category1);
33         $cloud->add_static($tag2, $count2, $category2);
34         $cloud->add_static($tag3, $count3, $category3);
35         my $html = $cloud->html_and_css(50);
36
37         # Obtaining uncategorized HTML for a categorized tag cloud.
38         my $html = $cloud->html_without_categories();
39
40         # Explicitly requesting categorized HTML.
41         my $html = $cloud->html_with_categories();
42

DESCRIPTION

44       The HTML::TagCloud module enables you to generate "tag clouds" in HTML.
45       Tag clouds serve as a textual way to visualize terms and topics that
46       are used most frequently. The tags are sorted alphabetically and a
47       larger font is used to indicate more frequent term usage.
48
49       Example sites with tag clouds: <http://www.43things.com/>,
50       <http://www.astray.com/recipes/> and
51       <http://www.flickr.com/photos/tags/>.
52
53       This module provides a simple interface to generating a CSS-based HTML
54       tag cloud. You simply pass in a set of tags, their URL and their count.
55       This module outputs stylesheet-based HTML. You may use the included CSS
56       or use your own.
57

CONSTRUCTOR

59   new
60       The constructor takes a few optional arguments:
61
62         my $cloud = HTML::TagCloud->new(levels=>10);
63
64       if not provided, levels defaults to 24
65
66         my $cloud = HTML::TagCloud->new(distinguish_adjacent_tags=>1);
67
68       If distinguish_adjacent_tags is true HTML::TagCloud will use different
69       CSS classes for adjacent tags in order to be able to make it easier to
70       distinguish adjacent multi-word tags.  If not specified, this parameter
71       defaults to a false value.
72
73         my $cloud = HTML::TagCloud->new(categories=>\@categories);
74
75       If categories are provided then tags are grouped in separate divisions
76       by category when the HTML fragment is generated.
77

METHODS

79   add
80       This module adds a tag into the cloud. You pass in the tag name, its
81       URL and its count:
82
83         $cloud->add($tag1, $url1, $count1);
84         $cloud->add($tag2, $url2, $count2);
85         $cloud->add($tag3, $url3, $count3);
86
87   add_static
88       This module adds a tag that does not link to another web page into the
89       cloud.  You pass in the tag name and its count:
90
91         $cloud->add_static($tag1, $count1);
92         $cloud->add_static($tag2, $count2);
93
94   tags($limit)
95       Returns a list of hashrefs representing each tag in the cloud, sorted
96       by alphabet. Each tag has the following keys: name, count, url and
97       level.
98
99   css
100       This returns the CSS that will format the HTML returned by the html()
101       method with tags which have a high count as larger:
102
103         my $css  = $cloud->css;
104
105   html($limit)
106       This returns the tag cloud as HTML without the embedded CSS (you should
107       use both css() and html() or simply the html_and_css() method). If any
108       categories were specified when items were being placed in the cloud
109       then the tags will be organized into divisions by category name.  If a
110       limit is provided, only the top $limit tags are in the cloud, otherwise
111       all the tags are in the cloud:
112
113         my $html = $cloud->html(200);
114
115   html_with_categories($limit)
116       This returns the tag cloud as HTML without the embedded CSS.  The tags
117       will be arranged into divisions by category.  If a limit is provided,
118       only the top $limit tags are in the cloud.  Otherwise, all tags are in
119       the cloud.
120
121   html_without_categories($limit)
122       This returns the tag cloud as HTML without the embedded CSS.  The tags
123       will not be grouped by category if this method is used to generate the
124       HTML.
125
126   html_and_css($limit)
127       This returns the tag cloud as HTML with embedded CSS. If a limit is
128       provided, only the top $limit tags are in the cloud, otherwise all the
129       tags are in the cloud:
130
131         my $html_and_css = $cloud->html_and_css(50);
132

AUTHOR

134       Leon Brocard, "<acme@astray.com>".
135
137       Copyright (C) 2005-6, Leon Brocard
138
139       This module is free software; you can redistribute it or modify it
140       under the same terms as Perl itself.
141
142
143
144perl v5.36.0                      2022-07-22                 HTML::TagCloud(3)
Impressum