Thanks for the post pippo!
I will look into that link you posted too.
At the moment, I'm working with something like this:
index.php - an example of one of the pages on the site.
the runtemplate() runs the template, but instead of echoing it to the screen, it returns the output as a string. That means I can have nested templates in any way I want, and they are all to be called by my code, rather than the templates.
$template['pagetype'] = 'index';
$row = getarticle();
$template['articletitle'] = $row['title'];
$template['articlename'] = $row['name'];
$template['articlebody'] = $row['body'];
$template['articleid'] = $row['id'];
$template['articlecopyright'] = $row['copyright'];
$template['titlecrumbs'] = "";
$template['panelimage'] = "$imagefolder/cat_index.gif";
$template['panelimagealt'] = "Main index";
$template['panelcaption'] = strtoupper(gmdate("F d, Y"));
$template['middlead'] = middlead();
$template['topad'] = topad();
$template['subnavigationitems'] = categories() . featuredarticles(8) . bestarticles(8);
$template['relatedpanelitems'] = signupbox() . insertspecials() . buttonad('index') . insertlinks();
$template['contentarea'] = runtemplate("contentarea-index.tpl.php");
For example, I have set the template variable contentarea to use the output from another template "contentarea-index.tpl.php". I have included templates in other places. For example, the signupbox() function runs a template called "signupbox.tpl.php". It is defined elsewhere!
I can modify the runtemplate() function at a later date to completely change the type of templates used, without touching my code! At the moment, the templates are in PHP format and they have access to the $template array.
Sample template - this is just a simple example, not an actual template.
I can easily add various different templates later as needed, for example, if I wanted a WAP interface.
<h3><?php echo $template['something.heading']?></h3>
<?php echo $template['something.body']?>
My question is: do you like this? Do you approve of it?
One of my concerns is that $template is an array, it doesn't have a hierarchical structure like XML, or in your case, classes that are inherited from classes above it.
I could do something like $template['main']['signupbox']['heading'] though. Arrays within arrays.