Comma-separated tags sidebar

Oct 15, 2006 00:04

Hi! I hope it's okay to post this here. I just switched to Mixit (which is directly based on Expressive), so I've been hacking at it a bit tonight, trying to bend it to my every whim.

I decided that I wasn't happy with the options of "cloud" or "list" for the tags sidebar module; the former looks cluttered to my eye, and the latter just takes up too much space with my plethora of tags. So using the framework of the existing function and some code I got from component_help a while back, I turned it into a simple comma-separated list.

Like so:


Yes, that's from my journal. Fear my mighty tags!

To achieve this effect, paste this entire function into your layout's theme or user layer. (If you already have a custom print_module_tags, you'll need to modify it or replace it entirely in order for this to work.) I've successfully tested this in both Expressive and Mixit, so it should work for both. Paid/permanent/early adopter users only, sorry! If you don't understand how layers work, please see this post for further information.

The code:

function print_module_tags(string title) {
var Page p = get_page();
var TagDetail[] tags = $p->visible_tag_list();
open_module("categories", $title, "");
var int tcount = 0;
foreach var TagDetail td ($tags) {
$tcount++;
var string uses = get_plural_phrase($td.use_count, "text_tag_uses");
var string security = $td.visibility;
""" $td.name""";
if($tcount < size($tags)) { print ", "; }
}
var string tags_url = $p.journal->base_url() + "/tag/";
print """
$*text_sidebar_tags\n""";
close_module();
}

Credits: None of this code is mine. The bulk of it was written by gameboyguy13 and posted publicly at component_help, and the rest came from the Mixit source code. I just combined them to make it work for Mixit and Expressive.

Questions? Problems? Comments?

how to:instructions, s2:theme layer, sidebar:tags, advanced, $acct level:paid or perm

Previous post Next post
Up