template question (or is it)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
griz
Forum Newbie
Posts: 5
Joined: Sat Jun 28, 2003 1:23 am

template question (or is it)

Post by griz »

I'm just starting php with this site:

http://www.3dmaniac.com/index2.php?file=members.php

As you may notice the url isn't set up good because if I needed to add another question mark after home.php I was told it can't be done. I would like to setup a system so that you would have to go to this url instead of above.

http://www.3dmaniac.com/members

Each section of this site has is included through:

<?
$docroot = getenv("DOCUMENT_ROOT");
$pathfilename = $docroot . "/" . $file;
?>

then inserted in by: <? include($pathfilename); ?>

I could go about this by making a separate template index2.php for every page. But that would be tedious. I know there is a better way because a ton of sites have it set up this way.

An example:
http://www.flashkit.com/tutorials/

I'm not asking for something to walk me through the whole thing, (all though it would be nice :D ), but for someone to just point me in the right direction.

Thanks
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Flashkit.com has two ways of doing that:

a) The 'tutorials' section is actually /tutorials/index.php , which is the most common way.

b) Their apache setup has mod_rewrite and mod_proxy, and they have a rewrite rule to catch /template/, and rewrite the URL string accordingly.
griz
Forum Newbie
Posts: 5
Joined: Sat Jun 28, 2003 1:23 am

Post by griz »

But about this.

http://www.phpfreaks.com/tutorials/71/0.php

how do they get the footer, header, and menu attached to the each and every page. I know they are using the inlcude function, but there must be something else. If they were just using the include they would have to make a separate template for 0.php, 1.php, 2.php, 3.php. Or maybe not.

So my question is, how do you get everpage to look the same through directories with using ONE TEMPLATE file.
Post Reply