[theme] - [component] - [tagcloud component]

Dec 14, 2005 13:18

in response to browneyedgirl65's component_help post.

var string header = "";
var string content = "";

var int int_groups = 5; # number of groups
var int int_percent = 20; # perecentage difference for each interval

$header = "Category Cloud";

var int adjust = 0; # font size adjustment
var int factor = 0; # factor of font size adjustment
var int interval = 0; # tag use count interval per group
var int max = 1; # max number of tag uses
var TagDetail[] my_tags = $p->visible_tag_list(); # list of visible tags

# implement cloudstyle ala delicious, etc
if ($my_tags) {
$content = $content + """

""";

# get max
foreach var TagDetail t ($my_tags) {
if($t.use_count > $max) {
$max = $t.use_count;
}
}

# now we get tag use count interval per group
$interval = $max / $int_groups;

# now print each item, and adjust its
# fontsize as a function of where in the
# continuum of $int_groups intervals it is
foreach var TagDetail t ($my_tags) {
# if we're not going to divide by 0
if($interval > 0) {
# get the proportion based on use_count and interval
$factor = $t.use_count / $interval;
} else {
# if we're dividing by 0, set factor to 0
$factor = 0;
}
$adjust = ($factor * $int_percent) + 100;
$content = $content + """ $t.name """;
}
$content = $content + """

""";
} else {
$content = $content + """
There are currently no tags or categories for this journal.
""";
}

print_comp_header($header);
print $content;
print_comp_footer();

function print_free_text, layout component

Previous post Next post
Up