The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount] [gradient strip] Adding a Counter
howto_user wrote in s2howto
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"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <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>";
      }
      $this->print_head();
    """</head>
  <body>""";
  $this->lay_print_header();
  $this->print_body();
  """<div style="text-align:center;">
    <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>
  </body>
  </html>""";
}

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.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account