Objects.
Create objects to represent your html code, for example, if you have a generic table format:
$table =& new TableObject();
$table->AddRow();
$table->AddColumn("Search Result");
$table->AddColumn("Search Rating");
foreach ($results As $result)
{
$table->AddRow();
$table->AddColumn($result['name']);
$table->AddColumn($result['rating']);
}
$table->Render();
Basic example.
We construct a TableObject. We call the AddColumn and AddRow methods of the object to add new rows/columns to our result set, finally, we call the objects Render method to output the HTML to the page.
The object is responsible for rendering.
This also means, you can use this object anywhere on your website - If you change the style of all table objects, you can just edit the render method of the table object, and have the changes reflect all over your site!
Same goes for creating other objects (Stuff like TextControl, SearchBox perhaps etc).
Basically, since using a template may be too restrictive, you can build your pages using objects as mentioned and be able to easily update the code.
Another tip is to have all your web objects inherit a basic component class:
class TableObject extends WebComponent
WebComponent may have simple properties such as Visible and Name.
Therefore, each object that inherits component, you can set a Visible on/off, and in your Render classes decide (depending if visible is on or not) whether you really do want to render the object or not.
Just an example, but im sure you would find using objects to be a lot easier.