Forum Moderators: coopster
I want to know how I can measure other pages into my template page. So what I mean is this; I create 1 page, 3 collumns, left for left menu, center for site contents and right for links, polls etc.. Now what I want to do it putt the contents on other simple pages (only text) and via the links in the menu on my template page measure these simple pages into my template page (eg. click the contact link then contact.php will be measured into template.php). So that when I make a change to the layout of my site (when it's getting big), I dont have to change it to every single page.
Infomation and links to webpages are very welcome!
write your template in html, then call your template template.inc.php
change every " mark in your template.inc.php to \" and every $ to \$
at the top of template.inc.php put:
<?php
function outputtemplate($content)
{
echo
"
and at the very bottom of tempate.inc.php put:
";
}
?>
in the place you want the content to appear, write:
$content
now we are done with the template. now to worry about the actual pages - just add to every page:
change every " mark in your page to \" and every $ to \$
at the top of page put:
<?php
$out=
"
and at the bottom:
";
include("template.inc.php");
outputtemplate($out);
?>;
Thank you soooooooo much! You made me very happy vincevincevince!
but now i saw something else how can I get this to work inside my contents pages?
<?php include ("codmp_news/news.txt");?>
I tried to remove the <?php and?> but it dint work (got error: "Parse error: parse error in /home/cth6249a/WWW/test1.php on line 11"), also I kept the " like they where, so I didnt change them to \"!
that is the only problem I have right now, thank you so much!
[edited by: jatar_k at 4:38 pm (utc) on July 15, 2003]
[edit reason] no personal urls thanks [/edit]
at the top put:
<?php
ob_start();
at the bottom put:
$content=ob_get_clean();
include("template.inc.php");
outputtemplate($content);
flush();
?>
what this does:
starts to store up all output sent by the script
instead of outputting to browser,it grabs it into a variable called $content
then it sends the content into the template, and outputs to browser
may not work for all scripts - you'll really have to try things to see how it goes - if not come back and ask the forum.