The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][opal] Adding a counter
howto_user wrote in s2howto
Because the Opal (Libra OSWD) 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 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.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account