Page 1 of 1
Should you use includes to build site?
Posted: Thu Oct 07, 2004 10:45 pm
by bradles
I'm designing my site that contains a header, navigation bar and footer that will be the same on each page. The only thing that will change will be the content.
Is it wise to design each page using includes: see my crude example below:
Code: Select all
<?php include 'header.php';?>
<?php include 'navigation.php';?>
<?php include 'contents1.php';?>
<?php include 'footer.php';?>
So you'd have a number of different contents pages that would load into the index page via your navigation. eg., contents1.php, contents2.php, contents3.php.
As I am still fairly new to php I just wanted to see if their is an ideal way to build a site without repeating too much code.
Any help would be greatly appreciated.
Brad.
Posted: Fri Oct 08, 2004 12:44 am
by feyd
templating is an oft recommended design which I am fond of. If the page content repeats a lot, you can create a function that does the ~unique content addition, along with all the repetitive bits. I try to avoid including too much because of HD seeks required to load the pages.
Posted: Fri Oct 08, 2004 12:52 am
by bradles
Thanks feyd,
How do you do templating? Is there a place you could recommend that will help get me started?
I must admit, a couple of times on my site i noticed it to be a bit slower than when I wasn't using PHP...I started to wonder if relying too much on PHP is a good thing? I want to keep my pages as quick as possible.
Brad.
Posted: Fri Oct 08, 2004 1:39 am
by feyd
this may be of help

Posted: Fri Oct 08, 2004 1:45 am
by mudkicker
I am a fan of templates, too and it is really useful if you have similar pages in your site.
an advantage of it, if you have an error in your site you can change / fix it only in one page not in all pages..
(this is very important for me as a lazy programmer

)
Posted: Sat Oct 09, 2004 1:34 am
by m3mn0n
I love templating also.
Seperating presentation from processing is genius.
Some helpful research links:
[big_search]php templating tutorial[/big_search]
Posted: Sat Oct 09, 2004 3:23 pm
by kaYak
You could use the Smarty template engine. That is what I use to build my sites with. You can find that at
http://smarty.php.net. It is fairly easy to use.

Posted: Sat Oct 09, 2004 5:51 pm
by mudkicker
techguy wrote:You could use the Smarty template engine. That is what I use to build my sites with. You can find that at
http://smarty.php.net. It is fairly easy to use.

is it useful even in very complicated php files?
i always stand away of smarty because of this..
what do you think?