Forum: Geek Forum
Topic: Utterly Stupid Question
started by: ShakerMaker

Posted by ShakerMaker on May 27 2002,09:16
Is there anyway of using say PHP to make a template file and use a line of code that inserts text into the html from a simple text file?  ??? If that makes any sense...


Posted by Beldurin on May 27 2002,19:41
Quote (ShakerMaker @ 27 May 2002,03:16)
Is there anyway of using say PHP to make a template file and use a line of code that inserts text into the html from a simple text file?  ??? If that makes any sense...

write the template in html, name it .php and then where you want to insert the text use the following command

Code Sample

<?
include("$DOCUMENT_ROOT/path/filename");
?>


Easy as pie.

edit: made the code stand out


Posted by ShakerMaker on May 28 2002,07:06
Quote (Beldurin @ 27 May 2002,11:41)
Quote (ShakerMaker @ 27 May 2002,03:16)
Is there anyway of using say PHP to make a template file and use a line of code that inserts text into the html from a simple text file?  ??? If that makes any sense...

write the template in html, name it .php and then where you want to insert the text use the following command

<?
include("$DOCUMENT_ROOT/path/filename");
?>

Easy as pie.

Holy shit! To easy! Thanks heaps!

Shouldn't that read:

<?php
include("$DOCUMENT_ROOT/path/filename");
?>

?

Thanks a million!
Posted by ShakerMaker on May 28 2002,07:27
Woohoo! It worked!

It works with html as well. :D

Is there a way to do this with only using one template?
So that every html file is opened in that ONE template?

Like on some sites I see the link that ends with: file.php?=100

How do I do that?


Posted by Beldurin on May 29 2002,18:36
1.)  you don't need the "php" in the <? tags...it works fine w/out it

2.)  I actually do it backwards from what you're asking.  What I do is I put all "common" design and layout elements before the page content into a header file, and all the layout stuff after the page content into a footer file.  Then, each individual display file looks like this.
Code Sample

<?
include("/SSIdirectory/header.php");
?>

page content, page content, page content, page content,
page content, page content, page content, page content,
page content, page content, page content, page content,

<?
include("/SSIdirectory/footer.php");
?>


bam!  now any layout/logo/color/design changes are only made in 1 file, and are reflected througout the site.  The file.php=100 is simply passing an arguement to the script, you can do all sorts of stuff w/that.  If you want some examples of PHP and these kinds of things, email me at beldurin@packethell.com.  Hope that helps!
Posted by Wiley on May 29 2002,20:43
Beldurin,
You have now exceeded the maximum number of helpful answers that you are allowed to give in the geek forum.  The only thing you are allowed to say for the durration of this thread is  ...h4h4, j00 h4v3 n0 l33t pHp 5k1llz l1k3 m3,  h4h4h4 l4m0r!!   :p
Posted by Beldurin on May 29 2002,21:24
Quote (Wiley @ 29 May 2002,14:43)
Beldurin,
You have now exceeded the maximum number of helpful answers that you are allowed to give in the geek forum.  

rofl...I almost fell out of my chair!  :D

Quote
The only thing you are allowed to say for the durration of this thread is  ...h4h4, j00 h4v3 n0 l33t pHp 5k1llz l1k3 m3,  h4h4h4 l4m0r!!   :p


um...what he said.  :D
Posted by ShakerMaker on May 30 2002,06:36
Thanks again Beldurin.  thumbs-up.gif
Powered by Ikonboard 3.1.4 © 2006 Ikonboard