[Phpwm] Site Structure

Iain Wallace iain at strawp.net
Mon Dec 12 07:08:39 GMT 2005



Matt Harris wrote:
> Hi Guys,
> 
> I've thought about going with something like this (see below).
> 
> My main index has two sets of includes, the action pages that talk to 
> the Db are included at the top of my page, before other output, so I can 
> use the header redirect. The other pages that include html/ output are 
> included in the content div.
> 
> Does that look ok?
> 
> Thanks again
> 
> Matt
> 
> ----------------------------index.php-----------------------------------
> <?php
> // db functions
> include_once "common_db.php";
> // include action pages before other output to enable redirect
> $page = (!empty($_GET['page'])) ? $_GET['page'] : null ;
> switch ($page){
> case 'addeventaction':
>    include('addeventaction.php');
>    break;
> }
> ?>
> <html>
> <head>
> <style media="all" type="text/css">
> #menu{
> width:25%;
> float:left;}
> #content{
> width:75%;
> float:left;}
> .horiz li{
> display: inline;
> }
> </style>
> </head>
> <body>
> <div id="menu">
>   <ul>
>     <li><a href="index.php?page=addevent">add event</a></li>
>     <li><a href="index.php?page=test">add event</a></li>
>     <li>link</li>
>     <li>link</li>
>     <li>link</li>
>     <li>link</li>
>   </ul>
> </div>
> <div id="content">
> <?php
>  // include other pages that dont use redirects
> $page = (!empty($_GET['page'])) ? $_GET['page'] : null ;
> switch ($page){
> case 'addevent':
>    include('addevent.php');
>    break;
> default:
>    include("welcome.php");
> }
> ?>
> </div>
> </body>
> </html>
> 
> 
> 
Looks OK. The only place you're really creating work for yourself is 
that if you want to add another page, you have to edit this one as well 
as creating the other one, whereas if you had pages including header at 
the top and footer at the bottom the only page that you have to edit is 
the new one. It's kind of keeping dependencies running from top to 
bottom in the code structure so that nothing at the top depends on 
anything beneath it.

Also: Please stop top-posting!

Cheers,
Iain



More information about the Phpwm mailing list