Changing some text in the TPAC

Out of the box, the TPAC includes a number of placeholder text and links. For example, there is a set of links cleverly named Link 1, Link 2, and so on in the header and footer of every page in the TPAC. Let’s customize that for our templates_BR1 skin.

To begin with, we need to find the page(s) that contain the text in question. The simplest way to do that is with the handy utility ack, which is much like grep but with built-in recursion and other tricks. On Debian-based systems, the command is ack-grep as ack conflicts with an existing utility. In the following example, we search for files that contain the text "Link 1":

Searching for text matching "Link 1". 

bash$ ack-grep "Link 1" /openils/var/templates/opac
4:            <a href="">[% l('Link 1') %]</a>

Next, we copy the file into our overrides directory and edit it with vim:

Copying the links file into the overrides directory. 

bash$ cp /openils/var/templates/opac/parts/topnav_links.tt2 \
bash$ vim /openils/var/templates_BR1/opac/parts/topnav_links.tt2

Finally, we edit the link text in opac/parts/header.tt2.

Content of the opac/parts/header.tt2 file. 

<div id="gold-links-holder">
    <div id="gold-links">
        <div id="header-links">
            <a href="">[% l('Link 1') %]</a>
            <a href="">[% l('Link 2') %]</a>
            <a href="">[% l('Link 3') %]</a>
            <a href="">[% l('Link 4') %]</a>
            <a href="">[% l('Link 5') %]</a>

For the most part, the page looks like regular HTML, but note the [%_(" ")%] that surrounds the text of each link. The [% ... %] signifies a TT block, which can contain one or more TT processing instructions. l(" ... "); is a function that marks text for localization (translation); a separate process can subsequently extract localized text as GNU gettext-formatted PO files.

NOTE. As Evergreen supports multiple languages, any customizations to Evergreen’s default text must use the localization function. Also, note that the localization function supports placeholders such as [_1], [_2] in the text; these are replaced by the contents of variables passed as extra arguments to the l() function.

Once we have edited the link and link text to our satisfaction, we can load the page in our Web browser and see the live changes immediately (assuming we are looking at the BR1 overrides, of course).