howto_user (howto_user) wrote in s2howto,

[paidaccount][flexible squares] Adding a counter

Because the Flexible Squares 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 the Flexible Squares style. 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.

In the Flexible Squares 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 Flexible Squares 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()
	var string header;
	var string text;

	$header = """<li class="sbartitle">Counter</li>""";
	$text   = """<li class="sbaritem">
	<a href="http://sm*******" target="_top">
	<img src="http://sm*******" alt="Site Meter" border="0" /></a>
	print_sidebar_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.

Tags: - flexible squares, counter, paid accounts only

Comments for this post were disabled by the author