The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][digital multiplex] Adding a counter
howto_user wrote in s2howto
Because the Digital Multiplex layout includes a Free Text module that allows the use of HTML, it is not necessary to use this tutorial to add a counter. The preferred method of adding a counter to layouts is through the Free Text option, which is explained here. This tutorial is being retained for historical and informational purposes only.

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 cover how to add a counter to the sidebar in Digital Multiplex (OSWD). It will override the function print_sidebar(Page p). 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.

In the Digital Multiplex layout, you can add an extra box to the sidebar and insert your counter HTML in it. Detailed information on adding sidebar boxes in the Digital Multiplex layout can be found here. You can use any counter that does not use JavaScript or server-side-scripting to do its tracking. This HowTo entry has information on counters in general. Specifically, the bottom of the post has information on where to find counters on the internet.

Once you have found a counter, you can use the following code to add it to your journal:

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

    print_sidebar_userpic();
    if ($*sidebar_position_one != "nothing") {
        if ($*sidebar_position_one == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_one == "navigation") {
            print_sidebar_navigation();
        } elseif ($*sidebar_position_one == "links") {
            $p->print_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 == "navigation") {
            print_sidebar_navigation();
        } elseif ($*sidebar_position_two == "links") {
            $p->print_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 == "navigation") {
            print_sidebar_navigation();
        } elseif ($*sidebar_position_three == "links") {
            $p->print_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 == "navigation") {
            print_sidebar_navigation();
        } elseif ($*sidebar_position_four == "links") {
            $p->print_linklist();
        } elseif ($*sidebar_position_four == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_four == "calendar") {
            print_sidebar_calendar();
        }
    }
    if ($*sidebar_position_five != "nothing") {
        if ($*sidebar_position_five == "summary") {
            print_sidebar_summary();
        } elseif ($*sidebar_position_five == "navigation") {
            print_sidebar_navigation();
        } elseif ($*sidebar_position_five == "links") {
            $p->print_linklist();
        } elseif ($*sidebar_position_five == "blurb") {
            print_sidebar_blurb();
        } elseif ($*sidebar_position_five == "calendar") {
            print_sidebar_calendar();
        }
    }

    $header = "Counter";
    $text   = """
    <a href="http://sm*.sitemeter.com/stats.asp?site=******" target="_top">
    <img src="http://sm*.sitemeter.com/meter.asp?site=******" alt="Site Meter" border="0" /></a>
    """;
    $id = "counter";
    print_sidebar_box($id, $text, $header);
}

Note that the counter code in orange is an example. It should be replaced by the code that you obtain from your counter site.

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 camomiletea.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account