Documentation Menu

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 15 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow patTemplate arrow Freqently Asked Questions arrow Can I re-use templates in different pages?

Can I re-use templates in different pages? PDF Print E-mail

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.
Tip

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 )
 
< Prev