PHP inlcudes() template theory
Posted: Tue May 12, 2009 7:35 pm
Hi everyone! I am new to PHP and am looking for some advice with my overall website template construct.
Right now I have a master template (aka my homepage, index.php) using includes() with header.php, navbar.php, left_col.php, right_col.php, and footer.php. (pretty standard i think).
index.php is in the root folder
header, navbar, left_col, right_col, and footer are in [root]/layout folder.
All my subpages are in the [root]/pages folder.
header, navbar, left_col, and footer will be staying the same on each page (well, left_col might change).
I basically wanna change out right_col for the different pages.
I understand I can just copy all the code in index.php into the different pages and the template will look the same... BUT, here's my question, is there an easier way to accomplish this (not that this is so hard)? Like, for instance if my template changes to three columns in the future, I would have to go into each subpage and update the general template!!! Is there anyway around this, like somehow being able to just call index.php (the master template) in my subpages and switch out right_col with the appropriate content?
Thanks in advance for all your replies!
Cheers,
Matt
Right now I have a master template (aka my homepage, index.php) using includes() with header.php, navbar.php, left_col.php, right_col.php, and footer.php. (pretty standard i think).
index.php is in the root folder
header, navbar, left_col, right_col, and footer are in [root]/layout folder.
All my subpages are in the [root]/pages folder.
header, navbar, left_col, and footer will be staying the same on each page (well, left_col might change).
I basically wanna change out right_col for the different pages.
I understand I can just copy all the code in index.php into the different pages and the template will look the same... BUT, here's my question, is there an easier way to accomplish this (not that this is so hard)? Like, for instance if my template changes to three columns in the future, I would have to go into each subpage and update the general template!!! Is there anyway around this, like somehow being able to just call index.php (the master template) in my subpages and switch out right_col with the appropriate content?
Thanks in advance for all your replies!
Cheers,
Matt