?

Log in

No account? Create an account

Previous Entry | Next Entry

Comma-separated tags sidebar

  • Oct. 15th, 2006 at 12:04 AM
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;
        """<a href="$td.url" title="$uses, $security">$td.name</a>""";
        if($tcount < size($tags)) { print ", "; }
    }
    var string tags_url = $p.journal->base_url() + "/tag/";
    print """<div class="widget-footer"><a href="$tags_url" title="$*text_sidebar_tags">$*text_sidebar_tags</a></div>\n""";
    close_module();
}


Credits: None of this code is mine. The bulk of it was written by jai_dit 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?

Comments

( 3 comments — Leave a comment )
oconel
Nov. 9th, 2006 01:01 pm (UTC)
It works! Thanks a lot for posting it. :D
waterofthemoon
Nov. 9th, 2006 05:21 pm (UTC)
No problem! Glad it worked for you. :)
atlantel
Oct. 13th, 2007 11:25 am (UTC)
thanks!

Do you know if it's possible to get it works with a different size for more used tags?
( 3 comments — Leave a comment )

Latest Month

March 2016
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

S2 Help Communities

Tags

Powered by LiveJournal.com
Designed by chasethestars