This tutorial will cover how to add a counter to the sidebar in Opal (Libra OSWD). It will override the function Page::lay_print_sidebar. 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 Opal 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 Opal 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 Page::lay_print_sidebar {
var string header;
var string text;
$this->lay_print_summary();
$this->print_linklist();
$this->lay_print_freetext();
$this->lay_print_calendar();
$header = "Counter";
$text = """
<div class="columnitem">
<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>
</div>
""";
print_box($header, $text);
}
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.