[Phpwm] Site Structure
Paul Cooper
pgc at openadvantage.org
Fri Dec 9 15:19:26 GMT 2005
On Fri, 2005-12-09 at 07:21 -0800, Steve Parkes wrote:
>
> On Fri, 9 Dec 2005 13:48:44 +0000, David Goodwin <david at codepoets.co.uk> wrote:
>
> >
> > The only problem with the above, is that as you rightly said, once
> > the header is included, if it writes out to the page, then it's not
> > possible to do any sort of session management or header stuff.
> >
>
> Pardon my general ignorance on the thread general death and distruction among my computers has put paid to following threads at all recently but is there some reason why the original poster isn't using output buffering?
>
> http://uk2.php.net/ob_start
>
> you can send a header at anytime
Or you can separate the decision of which php file to include and the
inclusion of that page, e.g.
<?php
$found = FALSE;
if(isset($_GET['page'])) {
$desired_page = $_GET['page'];
$allowable = array("index", "aboutme", "foo", "bar", "something",
"else");
foreach($allowable as $ok) {
if($ok == $desired_page) {
$include_page = $ok;
$found = TRUE;
continue;
}
}
}
include("header.php");
if($found) {
include($include_page)
} else {
include("default.php");
}
include("footer.php");
?>
In general this is one type of 'site structure' strategy: separate the
control of the application from the content of the page. Do all your
application logic at the top of the script, recording results in
variables (in above example $found and $included_page) and then build
you page layout once all that is done, either using includes, like
above, or some templating system like Smarty or HTML_Template_* in PEAR.
Paul
> sparkes
>
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> http://mailman.lug.org.uk/mailman/listinfo/phpwm
>
More information about the Phpwm
mailing list