Forum Moderators: coopster
Approach 1 -- Include the Content
E.g. a file named template.php loads content with a variable, template.php?content=thispage
template.php would work like this:
code . . . <include thispage> . . . code
Approach 2 -- Include the Layout
Every page would have its own file, e.g. thispage.php, which would work something like this:
<include top> . . . content here . . . <include bottom>
Which approach is better? Why?
Thanks for your help!
I always opt for whatever requires the least amount of work to achieve :) In this case that would be using one template and grabbing the content from a data source of some description. The main reason being that this removes the content from the presentation and makes re-designs and updates much easier.
I guess everyone is forgetting their manners ;)
coopster linked to a very good thread.
I don't think it is, necessarily, a question of what is better. It depends on what works better for you mostly.
One thing I would say though. I try to keep all query strings out of my urls unless absolutely unavoidable. In your first example I would embed the section or pageid/pagename in the code.
$content=thispage;
include "template.php";
Most often I go with the second option. Include the header, content and then include the footer. I also usually maintain title/meta tags on each page so I can customize them for each one.
This approach makes it very easy to change navigation (add another page to your system for example), or add tracking code to the footer.... many reasons I would take this approach.
Best regards
Shady