The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][asg] Adding a tag list to the sidebar
howto_user wrote in s2howto
Paid Accounts Only
The following tutorial requires creating and editing a custom style, which in turn requires a paid, permanent, or early adopter account. Please read What are the paid account benefits? and How do I buy a paid account? to learn about the paid account benefits and how to buy a paid account.

This tutorial will explain how to add a tags list to the sidebar in A Sturdy Gesture. It will override the function Page::lay_navbar. This new code will be placed in a theme layer. If you already have a theme layer, you will need to edit it and add the code below. If you do not have a theme layer, you will need to create one by following the instructions in the Theme Layer tutorial.

In the A Sturdy Gesture layout, you can add add a list of your tags in an extra sidebar box, using the code below. Note that if your theme layer already has function Page::lay_navbar, you will need to modify it to include the code highlighted in orange. Otherwise, copy and paste the following code into the layer, making sure to include everything:

function Page::lay_navbar() {
    var string userpic;
    var Image up_img = $.journal.default_pic;
    if (defined $up_img) {
        $userpic = """<div class="userpic">
<img src="$up_img.url"
     class="userpic" alt=""
     height="$up_img.height" width="$up_img.width" />
</div>
""";
    }
    var string website;
    if ($.journal.website_url != "") {
        $website = """<li><a href="$.journal.website_url">
                        $.journal.website_name</a></li>\n""";
    }

"""

<td id="navbar" width="25%">
<div class="box">
<h1>$.journal.name</h1>
<ul>
""";
    foreach var string v ($.views_order) {
        if ($.view == $v) {
            println "<li class=\"active\">"+lang_viewname($v)+"</li>";
        } else {
            println "<li><a href=\""+$.view_url{$v}+"\">"
                             +lang_viewname($v)+"</a></li>";
        }
    }
"""
$website</ul>

$userpic
</div>
""";

    if ($this->lay_show_firstnav()) {
        $this->lay_page_nav();
    }

    if (size $this.linklist > 0 and $*linklist_support) {
        println "<div class=\"box\">";
        println "<h2>Links</h2>\n";
        $this->print_linklist();
        println "</div>";
    }


var TagDetail[] visibletags = $this->visible_tag_list(); if (size($visibletags) != 0 and $this.view != "friends") { println "<div class=\"box\">"; println "<h2>Tags</h2>\n<ul>"; foreach var TagDetail td ($visibletags) { """<li><a href="$td.url">$td.name</a></li>\n"""; } println "</ul>"; }
"</td>"; }

This code will add a tag list to the sidebar in all journal views except the friends view. If you would like to see your tag list also on your friends page, remove the text highlighted in yellow.

Compile your layer, and it's ready to use. You will need to apply your theme layer via the Customize interface in order for your changes to take effect.

Compiled by tell_me. Based on a tutorial contributed by camomiletea.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account