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:
<patTemplate:tmpl name="header"> <h1>My Superhero database</h1> </patTemplate:tmpl>
<patTemplate:tmpl name="footer"> <hr/> <span class="footer">Superhero database was last updated on 2001-12-24 (Oh, christmas).</span> </patTemplate:tmpl>
Now you may include these two files in all other pages by using the src attribute of the <patTemplate:tmpl> tag:
<patTemplate:tmpl name="page"> <html> <head> <title>Any page of the superhero database</title> </head> <body> <patTemplate:tmpl name="includedHeader" src="header.tmpl" parse="on"/> Here is the rest of the page... Can be anything from static HTML to other templates. <patTemplate:tmpl name="includedFooter" src="footer.tmpl" parse="on"/> </body> </html> </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.