Includes Within Includes -
05-25-2004
, 10:28 PM
I'm now able to make and display MySQL tables, using PHP, and I'm
playing with all kinds of ideas for streamlining my websites.
Let's use a 50-states site as an example. Rather than create 50 web
pages - one for each state - and pasting an article about each state on
each page, I'm thinking of writing 50 articles and putting them in a
database. I'll still have 50 web pages, but each page will simply
include a PHP function that fetches the appropriate article.
But I'm thinking of taking it one step further. At present, each page
looks something like this:
<head>
</head>
<body>
<div class="body2">
<div class="body3">
[PHP INCLUDE FOR TOP SECTION]
<table class="tabmain">
<tr>
<td class="tdleft"></td>
<td class="tdcenter">[PHP INCLUDE FOR ARTICLE]</td>
<td class="tdright"></td>
</tr>
</table>
[PHP INCLUDED FOOTER]
</div>
</div>
</body>
What I'm now thinking of doing is putting EVERYTHING between the body
tags in an include, so the page would look like this:
<head>
</head>
<body>
[ONE BIG PHP INCLUDE]
</body>
.... and the included page would look like this:
<div class="body2">
<div class="body3">
[PHP INCLUDE FOR TOP SECTION]
<table class="tabmain">
<tr>
<td class="tdleft"></td>
<td class="tdcenter">[PHP INCLUDE FOR ARTICLE]</td>
<td class="tdright"></td>
</tr>
</table>
[PHP INCLUDED FOOTER]
</div>
</div>
Is this a good plan, and what would the includes in the included page
look like - just like regular includes?
At present, my includes look like this:
<?php include ($seg."a1/inc/toptopics.php"); ?>
where $seg represents the relative distance to the site's home page,
like ../ or ../../
I might be able to build the top section and footer into the body
section, so I wouldn't need to include them. However, I'd like to retain
a little flexiblity, in case I need different page structures for
certain sections of my site. Or maybe I'll just make three or four
master pages that include everything - top section, main table and
footer. But I'd still have to include the articles.
Any tips?
Thanks. |