Header and Footer Variables

When you learned how to create headers and footers in Headers and Footers, you probably noticed the %PAGENUM%, %PAGETOTAL%, and %H1% variables. When Highwire™ sees these variables in the header or footer, it automatically replaces them with the current page number, total number of pages, and the contents of the last <h1> tag, respectively. These variables are built-in to Highwire.

Highwire's <ctvar> tag lets you define custom variables. Variables, which must begin and end with a percentage sign (e.g., %USERNAME%), can be used as placeholders in headers and footers for information that may change on a document-by-document, or even page-by-page basis. When Highwire sees these variables in a header or footer, it replaces them with text or an HTML string.

A variable should be defined using the <ctvar> tag in the <head> section tag of the document. It can be redefined using a <ctvar> tag at any point in the document. You should set the name attribute of this tag to the variable name (remember to begin and end the name with a percentage sign), and the value attribute of this tag to the text or HTML code with which Highwire should replace the variable.

For example, the code below defines a variable of %AccountOwner% with a value of John Doe.

<!-- <ctvar name="%AccountOwner%" value="John Doe"/> -->

This variable can be useful, for instance, if we were to put it in the <head> tag of a document that linked to a Highwire template file with the following header definition:

<ctheader><p>Quarterly 401k Account Report for %AccountOwner%</p></ctheader>

When Highwire creates this PDF document, the resulting header is:

<p>Quarterly 401k Account Report for John Doe</p>

This allows us to use the same header for many documents (since the header is in a Highwire template file), but to change the name used in the header on a document-by-document basis with the <ctvar> tag.

The <ctvar> tag also allows us to change headers and footers on a section-by-section basis. For example, suppose we have a Web document that is divided into a number of chapters. To get the footer to change whenever we start a new chapter, we can create the following footer:

<ctfooter><p align="right">Chapter %CHAPTERNUM%, "%CHAPTERTITLE%"</p></ctfooter>

Then, whenever we start a new chapter in the document, we can define the %CHAPTERNUM% and %CHAPTERTITLE% variables so that they reflect the current chapter. The example below illustrates this technique.

Using Section Variables for Footers

<html><head>

<!-- <ctfooter><p align="right">Chapter %CHAPTERNUM%, "%CHAPTERTITLE%"</p></ctfooter> -->

<!-- <ctvar name="%CHAPTERNUM%" value="1"/> -->

<!-- <ctvar name="%CHAPTERTITLE%" value="Introduction"/> -->

</head><body>

<h1>Chapter 1, Introduction</h1>

 

...

 

<br style="page-break-before:always"/>

<!-- <ctvar name="%CHAPTERNUM%" value="2"/> -->

<!-- <ctvar name="%CHAPTERTITLE%" value="Getting Started"/> -->

<h1>Chapter 2, Getting Started</h1>

 

...

</body></html>

Note: The task above can more easily be accomplished with the %H1% pre-defined variable. See Predefined Header and Footer Variables for information about this variable.