Page Template Design Problems

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
lexon
Forum Newbie
Posts: 1
Joined: Mon Apr 03, 2006 1:47 am

Page Template Design Problems

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
Post Reply