Can I re-use templates in different pages?

Of course you can. Let's say you'v got a footer and a header, which should be the same in all of your pages, so you have to change it only once and it will be updated in all pages.
To accomplish this, at first create the two files, and save them to your template directory as header.tmpl and footer.tmpl.
The templates could look like this:

001    <patTemplate:tmpl name="header">
002          <h1>My Superhero database</h1>
003    </patTemplate:tmpl>

and this:

001    <patTemplate:tmpl name="footer">
002          <hr/>
003          <span class="footer">
004     Superhero database was last updated on 2001-12-24 (Oh, christmas).
005       </span>
006    </patTemplate:tmpl>

Now you may include these two files in all other pages by using the src attribute of the <patTemplate:tmpl> tag:
Furthermore there is a second template called dropdown_entry. This template will be used to dynamically build the drop down list. The template type is set to condition as there may be two modes for each entry. Eitherit is selected by default or it isn't.

001    <patTemplate:tmpl name="page">
002          <html>
003                <head>
004                      <title>Any page of the superhero database</title>
005                </head>
006                <body>
007                      <patTemplate:tmpl name="includedHeader" src="header.tmpl" parse="on"/>
008                      Here is the rest of the page...
009                      Can be anything from static HTML to other templates.
010                      <patTemplate:tmpl name="includedFooter" src="footer.tmpl" parse="on"/>
011                </body>
012          </html>
013    </patTemplate:tmpl>

You may adress the header and footer templates as if the were written directly into the page but you have to change them only once, so this is some kind of include() for templates.

Organizing templates in folders
Of course you may also organize templates in subfolders. If you'd like to put the shared templates in a subfolder of your template folder, just use <patTemplate:tmpl src="shared/header.tmpl" parse="off">. patTemplate will then load the template from ./templates/shared/header.tmpl if your basedir is set to templates.

Last Updated ( Tuesday, 01 November 2005 )