Templates can bring order and structure to a web site. In this article I
describe how templates can be used to control the page layout for a site
that is currently composed of many pages of static HTML, using a popular
template class and a new feature of PHP4.
But first, let's set the scene. There are two distinct motivations for
to separate functionality (PHP) from layout (HTML)
to avoid duplication of repeated elements
Separating Functionality from Layout
The first motivation is the most-often discussed. Here the situation is that a
group of programmers produce PHP scripts to generate the content of a page,
whilst a group of graphic designers produce HTML and images to control the
appearance of the finished page. The idea is to allow both groups to work on
independent sets of files. The programmers can work on files that contain only
PHP, without concerning themselves with producing nicely presented HTML, whilst
the graphic designers can work on the layout of the page using their favourite
visual editor, without worrying about breaking any embedded code.