...

View Full Version : best Way To Use Include() For Managing the Site's Layout



inVINCEable
06-01-2007, 01:20 AM
I am able to successfully develop the layout of my site on one page, using one html file and one css file. This particular page has a header, 3 columns (furthermost left is navigation, center is content, and far right is advertisement), and a footer.


My question to you all, what is the best way to use PHP's include function to help keep my layout consistent?

I was thinking I create my navigation bar, header, sidebar, content, and footer all in seperate .php files, and then simply include them on my index.php page. Is this the best way to do it? It this the way most people do it here?

Thanks for any input/advice on the subject matter.

wicked_ryoko
06-01-2007, 01:41 AM
That's an easy way to do it. It beats having to do each page in complete html, that's for sure.

inVINCEable
06-01-2007, 01:49 AM
And one more question, if I use this method and put in let's say my header.html file <div id="header"></div> and refer to this in my index.php file as

include("header.php");

would that be correct or should I just do the header in the header.php file and leave the <div id="header"> in my index.php file.


Basically what I am asking is should I leave the <div id="idnamehere"></div> in my index.php file, or should I put them all in the individual files?


Which way would be easier to manager with css?

Thank you.

whizard
06-01-2007, 01:53 AM
It shouldn't matter too much, since whether the div is in the include or the individual pages, all you have to do is update the CSS to change the div.

Dan

inVINCEable
06-01-2007, 02:21 AM
It shouldn't matter too much, since whether the div is in the include or the individual pages, all you have to do is update the CSS to change the div.

Dan


Thanks, I went ahead and just put the <div id="idnamehere"></div> elements in my index.php file. Just seemed like a good thing to do, I guess it is just a preference then.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum