Page 1 of 1

Page Template Design Problems

Posted: Mon Apr 03, 2006 2:13 am
by lexon
I've recently tried to design a template system but things haven't ran so smoothly. This is my first time btw,
Im using different methods to display different parts of my site ... ie, Header method to display the <html> tag through to <body> tag... etc..
In the end i just use another method (Display()) to call on them.

The problem I have is I can't use a variable from by body to the <title></title> tags becasue the header method is excuted first, then the body method is excuted.

Anyone have any way to go by this? I've been thinking about formatting my page first and put the output it in a variable or something... and then call the display() function so that I already have what I want in the <title> tags ready.

Help Plz... ~~~ Me a design noob

Also, do you know any gd place to find stuff about CMS designs? preferrably using objects...

Thnx ALOT

LeXon

Posted: Mon Apr 03, 2006 9:49 am
by pickle
Make your functions return the code they generate rather than echo it. That way, you can execute them in any order, and echo the results when everything's done.

Posted: Mon Apr 03, 2006 10:22 am
by John Cartwright
How I accomplished this in the past is by combining the header content page and footer before processing

semi pseudo:

Code: Select all

$loadTemplates = array(
   'header.tpl',
   $requestedTemplate.'.tpl',
   'footer.tpl'
);

$overallTemplate = '';
foreach ($loadTemplates as $template) {
   $file .= file_get_contents($template);
}
then I can do the variable processing