The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][haven] Adding and re-arranging sidebar boxes
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 is an overview of how to add or re-arrange sidebar boxes in Haven. It will override the function print_sidebar(). This requires the creation of 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.

Adding sidebar boxes

To add a box to the bottom of the sidebar you will need to insert the following code into your theme layer, making sure to copy everything:

function print_sidebar()
{
    var string header;
    var string text;

    print_sidebar_userpic();
    if ($*sidebar_position_one != "nothing") {
        if ($*sidebar_position_one == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_one == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_one == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_one == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_two != "nothing") {
        if ($*sidebar_position_two == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_two == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_two == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_two == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_three != "nothing") {
        if ($*sidebar_position_three == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_three == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_three == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_three == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_four != "nothing") {
        if ($*sidebar_position_four == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_four == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_four == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_four == "calendar") {
            print_sidebar_calendar();
        }
    }

$header = "Your Header"; $text = """ Your text/HTML here """; print_sidebar_box($header, $text);
}

Change "Your Header" to whatever you wish your header to be and add the contents of your box in the indicated place. Note that you will need to format the text with HTML, as it will not be auto-formatted.

You can add as many new boxes as you wish by repeating the code highlighted in orange.

Displaying sidebar boxes on certain view types

The sidebar boxes will normally appear on all the views of your journal. However, if you wish the sidebar to have different boxes depending on the page type or if you simply don't wish to clutter other pages, you can select where you would like the sidebar box to appear. You can choose one of the following view types: recent, friends, archive, month, day, entry, reply. For the explanations of what each view is, please see the overview of S2 View Types.

The following code adds a sidebar box to display only on your Recent entries page. Again make sure to copy everything. Replace recent with one of the view types listed above if you wish it to display on a different view type.

function print_sidebar()
{
    var string header;
    var string text;
    var Page p = get_page();

    print_sidebar_userpic();
    if ($*sidebar_position_one != "nothing") {
        if ($*sidebar_position_one == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_one == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_one == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_one == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_two != "nothing") {
        if ($*sidebar_position_two == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_two == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_two == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_two == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_three != "nothing") {
        if ($*sidebar_position_three == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_three == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_three == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_three == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_four != "nothing") {
        if ($*sidebar_position_four == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_four == "links") {
            print_sidebar_linklist();
        } elseif ($*sidebar_position_four == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_four == "calendar") {
            print_sidebar_calendar();
        }
    }

if ($p.view == "recent") { $header = "Your Header"; $text = """ Your text/HTML here """; print_sidebar_box($header, $text); }
}

Re-arranging sidebar boxes

In Haven, the order of most of the sidebar boxes is determined by the properties which you can set on the Customize page. However, in these settings it is not possible to change the position of the Profile box, which is first by default, or of any boxes which you add on. Should you wish to do it, you will need to use the following code and rearrange the lines that start with "print_sidebar_", but be sure to keep the code in orange together. Note that if you use this code, you will no longer be able to change the order in the settings on the Customize page.

function print_sidebar()
{
    var string header;
    var string text;

    print_sidebar_userpic();
    print_sidebar_linklist();
    print_sidebar_calendar();
    print_sidebar_summary();
    print_sidebar_blurb();
    print_sidebar_calendar();

$header = "Your Header"; $text = """ Your text/HTML here """; print_sidebar_box($header, $text);
}

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.

Contributed by </a></b></a>camomiletea.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account