Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 189
0 Users 11 Guests Online

Split Layout

Say you have a layout that has tons of HTML and all that and you do not want to waste space of putting all html in every file you have to deal with.

First off, make new folder and call it Inc

Next make two files one named head.inc.php and another called foot.inc.php

You do not want just .inc files or people(Rippers) can steal your layout and possibly file lawsuit.

In your head file you will want to post ALL the HTML until the point of the actual content such as news and all that.

In the footer file you will post the remaining bits of HTML at the top ending the main content area.

Next in all the files you have that need the HTMl and all that you could do:
PHP Code
1
2
3
4
5
6
7
8
<?php
require("Inc/head.inc.php"); //get header
?>
your content in this area :)
<?php
require("Inc/foot.inc.php"); //get footer
?>


This will grab all your HTML and you do not have to put it on all the pages you have.

And just a tip here... if you put
PHP Code
1
2
3
4
5
<?php
session_start
();
include(
"config.php");
?>


At the top you will only have to do that 1 time instead of all the files that need to get configuration files and information.

And if you use This tutorial it will go for the whole website instead of just the pages you want.

Or if you want to do something more advanced you could use a switch get function in a file called nav.php then in a separate folder named pages you could have all your files then your index.php

Could have something like...
PHP Code
1
2
3
4
5
6
<?php
require("Inc/head.inc.php"); //get header
require("nav.php"); //get navigation file
require("Inc/foot.inc.php"); //get footer information
?>


Thats that then in your nav.php you could have something like...
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$dir 
"pages"//where your pages are
$ext "php"//their extennsion
switch($_GET[x]){ //change some links to... ?x=case
default: //default page
require("$dir/home$ext"); //get the main page with news or updates and whatnot
break; //end that page
case 'login'//your login page
require("$dir/login$ext"); //get your login file
break; //end page
//end switch/get function
?>


Then that would most likely leave a nice organized directory.

this here is a simple listing of how i have setup one or two of my sites:
Code

--MAIN
--inc
-header.inc.php
-footer.inc.php
-config.db.inc.php
--images
--pages
--admin
--members
-main.php
-login.php
-index.php
-nav.php


Keeps all the pages separate and organized so you can find things easier.

Hopefully this tutorial/guide has helped you split your layout into header files and footer files and taught you something :P
ShadowMage
Author:
Views:
2454
Rating:
Posted on Saturday 10th November 2007 at 12:03 PM
awo
awo
okey
Posted on Saturday 10th November 2007 at 02:47 AM
ShadowMage
ShadowMage
Nope, thats the nap.php which is used as an include on the index.php
Posted on Friday 9th November 2007 at 11:42 PM
awo
awo
Is this code a include????


Code


<?php
$dir = "pages"; //where your pages are
$ext = "php"; //their extennsion
switch($_GET[x]){ //change some links to... ?x=case
default: //default page
require("$dir/home$ext"); //get the main page with news or updates and whatnot
break; //end that page
case 'login': //your login page
require("$dir/login$ext"); //get your login file
break; //end page
} //end switch/get function
?>

Posted on Thursday 8th November 2007 at 09:25 PM
gbt91
gbt91
awo actually this is a tutorial site so he doesnt need to upload an example...
you just need to read the tutorial to learn how to do that not to copy it
Posted on Thursday 8th November 2007 at 04:52 PM
awo
awo
Can you Upload a exsempel???