Hello, All!
Is it possible to create one wrapper file that can contain and place the header, navs, footer, and any other repeating pieces of code? Presently, I build sites using the following structure:
<?php
require "header.php";
require "navs.php";
require "title.php";
?>
Page specific content goes here.
<?php require "footer.php"; ?>
After a friend showed me the one streamlined wrapper file he uses when he develops ColdFusion pages, the multiple-require structure above seemed unwieldy by comparison. I wonder if PHP has the same ability.
Thank you for your help!
Pat
Wrapper file that contains header, navs, and footer
Moderator: General Moderators
It's possible to build a site around a single index.php file, using query strings to pass page information.
index.php would include the entire template and all shared functions, and would do a conditional include of whatever page was requested via query string.
e.g. index.php?page=hello (or even index.php?hello, using some trickery), could cause the page hello.php to be included and parsed. The hello.php file would never be accessed directly (and often you'd want to explicitly prevent that).
index.php would include the entire template and all shared functions, and would do a conditional include of whatever page was requested via query string.
e.g. index.php?page=hello (or even index.php?hello, using some trickery), could cause the page hello.php to be included and parsed. The hello.php file would never be accessed directly (and often you'd want to explicitly prevent that).
-
pbritten
- Forum Newbie
- Posts: 13
- Joined: Wed Mar 24, 2004 9:24 am
- Location: State College, Pennsylvania, USA
Feyd,
Thank you for the link to "templates". I must admit that I'm slower than the average bear with these things. I did indeed read through many threads on this wonderful site, but couldn't interpret them as the answer. Perhaps it's because the necessary code to do this is much different than the level of PHP that I'm currently writing.
Might you know of a book or resource that provides a step-by-step guide to building the wrapper concept?
Thank you very much!
Pat
Thank you for the link to "templates". I must admit that I'm slower than the average bear with these things. I did indeed read through many threads on this wonderful site, but couldn't interpret them as the answer. Perhaps it's because the necessary code to do this is much different than the level of PHP that I'm currently writing.
Might you know of a book or resource that provides a step-by-step guide to building the wrapper concept?
Thank you very much!
Pat
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
McGruff can probably better point you, as I only have 1 book on php, which is all advanced stuff... However, I can recommend the design pattern books