Tag Cloud in the Sidebar

Oct 14, 2006 23:35

I know this is long overdue, and many people have been asking for it, so here it is: a tutorial for adding a tag cloud into the sidebar in Smooth Sailing. It is for paid users only as it requires a function override. Please read comments in green and only change code in red.


# Function to print a tag cloud in Smooth Sailing's sidebar.
function Page::lay_print_sidebar_tags() {

# Configurable Settings - you can change what is in red.
var int minSize = 10; # minimum size of tag links, in pixels
var int maxSize = 24; # maximum size of tag links, in pixels
var string tagPageLinkText = "View my Tags Page"; # text to link to the tags page

# Do not edit anything under this line unless you know what you are doing.
var TagDetail[] pagetags = $this->visible_tag_list();
if (size($pagetags) < 1) { return; }
var int most_count = 1;
$this->lay_print_sidebox_top($*text_sidebox_tags_title);
"""
    """;
    foreach var TagDetail td ($pagetags) {
    if ($td.use_count > $most_count) { $most_count = $td.use_count; }
    }
    foreach var TagDetail td ($pagetags) {
    var string uses = get_plural_phrase($td.use_count, "text_tag_uses");
    var string security = $td.visibility;
    var int tagtextsize = $minSize;
    if ($td.use_count > 1) {
    $tagtextsize = (($maxSize-$minSize)*$td.use_count)/$most_count + $minSize;
    }
    """
  • $td.name
  • """;
    }
    """

""";
if ($tagPageLinkText!="") { """ $tagPageLinkText"""; }
$this->lay_print_sidebox_bottom();
}

You must also place the following CSS in your stylesheet or into the Custom CSS box in the Custom Options area:

#tags_sidebox ul { margin: 0; padding: 0; }
#tags_sidebox li { display: inline; margin: 4px; }

Mike.

sidebar, tag cloud, tutorial

Previous post Next post
Up