Forum Moderators: coopster

Message Too Old, No Replies

Using a template.

Measure simple pages into a template page

         

JQuake

10:24 am on Jul 13, 2003 (gmt 0)

10+ Year Member



Ok please note that my english isn't my best, so i'll try to explain what i mean.

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!

vincevincevince

10:49 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



do these simple steps, exactly, in this order:

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);
?>;

JQuake

11:40 am on Jul 13, 2003 (gmt 0)

10+ Year Member



YEEEEEEEAAAAAAAAAAAHH! YES YES YES!

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!

vincevincevince

12:07 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you'll have to use a little alternative to include:

put the following into the page, exactly, NOT changing the " to /", and including the " around it all (replacing the <?php include ("codmp_news/news.txt");?>)


".file_get_contents("codmp_news/news.txt")."

JQuake

12:23 pm on Jul 13, 2003 (gmt 0)

10+ Year Member



HAHAHAHA! YES Thank you everything is working fine now! Is there anyway I can do something back for you? Because you helped me sooooo much :D :D :D

vincevincevince

12:26 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm glad it worked out for you.

JQuake

10:04 am on Jul 15, 2003 (gmt 0)

10+ Year Member



Hi vincevincevince I hope you are still around here somewhere, the script you gave me works very GREAT and i'm very HAPPY with it, also with the alternative for the include function. But i figured out some more dont work, like these ones: include_once(), require(), require_once() do they also have alternative functions that work for the site? I downloaded some scripts from hotscripts and some use these functions.

JQuake

10:07 am on Jul 15, 2003 (gmt 0)

10+ Year Member



btw vincevincevince here is the link to my website: <snip> its not officially open yet, but because you helped me so much i'll give you a sneak peek. Everybody thats not vincevincevince don't click that link ;)

[edited by: jatar_k at 4:38 pm (utc) on July 15, 2003]
[edit reason] no personal urls thanks [/edit]

vincevincevince

8:04 pm on Jul 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if you want a dynamic script to output into your template, TRY this with the script page:

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.