Add Page Numbers

THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO

In this tutorial, you will learn how to add page numbers to your web publication.

You may want to include the page number and the total number of pages in your web publication. Page numbers, along with the breadcrumb are two useful indicator of where a reader is in a publication.

Add the page elements to the template

To add the page elements to the template, follow these steps:

  1. Select the Collection tab;
  2. Click on the small e button beside the templates drop down list;
  3. Select the publication template to open it for editing;
  4. Once in the temple, locate the place where you want to add the page numbers;
  5. Copy and paste the makup below.
XSLT
<!-- page / pages -->
<xsl:if test="$page_num">
 <div class="pagenums">
  <xsl:value-of select="$page_num"/> / <xsl:value-of select="$page_total"/>
 </div>
</xsl:if>

The above markup first checks if the page number parameter was sent to the template, it then creates a div element in which are inserted the two parameters.

Tip

To insert the page numbers near the Back link at the bottom of the page, look for the following makup:

XSLT
<!-- back bottom -->
<div class="back">
 <a href="javascript:history.go(-1);">Back</a>
</div>			

After you seved the template, you can publish your collection to see the result. Altough it might not look like you expected.

Add the pagenums selector to the stylesheet

It's now time to add a bit of style to the pagenums element.

To add the appropriate style, follow these steps:

  1. Select the Content or Topic tab;
  2. Click on the small e button beside the stylesheets drop down list;
  3. From the popup menu, select the publication main stylesheet;
  4. Once in the stylesheet. find the div.back selector;
  5. Copy and paste the selector below just above the dv.back selector.
CSS
div.pagenums {float:right; margin-right:8px; font-size:0.82em; 
              clear:both;}	

In the above selector, the page numbers are floated to the right (float:right;). The selector also makes sure the page numbers stacks well with the back link by using clear:both;.

Once your style selector is added and your stylesheet saved, you can refresh your browser to see the final result.

THESE PAGES ARE STILL UNDER CONSTRUCTION AND DO NOT NECESSARELY REFLECT THE CURRENT VERSION OF TÓPICO

63 / 194