howto_user (howto_user) wrote in s2howto,

[paidaccount] [gradient strip] Adding a Counter

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 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 Gradient Strip layout, a counter can be added to the bottom of the page by overriding the Page::print() function. You can use any counter which does not require JavaScript or server-side scripting to do its tracking. General information about counters, including information on where to find them online, is available in the HowTo journal.

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

function Page::print() {
  var string title = $.global_title;
  var string subtitle = $.global_subtitle;
  var string view_title = $this->view_title() != "" ? $this->view_title() : "Unknown View";

  """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  <html xmlns="">
    <title>$title :: $view_title</title>""";
      if ($*external_stylesheet) {
        """<link rel="stylesheet" href="$.stylesheet_url" type="text/css" />""";
      else {
        """<style type="text/css">"""; print_stylesheet(); "</style>";
  """<div style="text-align:center;">
    <a href="http://sm*******" target="_top">
    <img src="http://sm*******" alt="Site Meter" border="0" /></a>


Note that the counter code in orange is only an example. You will need to replace it with the code that you get from your counter site.

Once you have finished adding the code above, you can save your theme layer by clicking on the "Save & Compile" button at the top of the screen. Your changes will not take effect until you apply your theme layer by selecting it on the Customize Journal page.

NOTE: The function which this tutorial overrides controls the entire layout of your journal. Be careful to not change or delete anything other than the section in orange, as errors may cause serious problems with the display of your journal.

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

Tags: - gradient strip, counter, paid accounts only

Comments for this post were disabled by the author