Thursday, September 27, 2012

Php using page partitions.

When writing scripts in php a good way to handle mapping a site is by establishing Page Partitions. Page parts will allow you to not have to keep re-writing headers, menus, contents, footers and sections repeatedly throughout all your sites pages. And then you can call them in using Php when and where you need them.
 The idea behind this is to have a MVC type plan to not repeat anything over and over again.
    Create your sites first page. Then break it up into sections. Then Place these sections copied into a page named after them like--header.php, content.php, leftmenu.php, rightmenu,php, footer,php. Things that normally will not change. Next we will call them into our programmed pages as we need them using the Includes Function. Below we show you how this is done.

Do code

Do code

?php

incude('header.php');
?

Show html and other code sections etc.


?php

include('leftmenu.php');
?

Show html and other code sections etc.


?php

include('content.php');
?

Show html and other code sections etc.


?php

include('footer');
?

Show etc.




 

1 comment:

  1. As you get familiar with doing this above then you can use conditional IF statements to call in changes like-->

    ?php
    if user = $true;
    {
    include(leftmenu.php');
    } else {
    include(usersmenu.php');
    }
    ?

    ReplyDelete