Zesix Interactive Sponsor: Teen Forums Sig of the WeekMySigsClan Templates

Go Back  
Reload this Page PHP Navigation System
 

Tutorials
Post a tutorial that you think others can benefit from

Reply
 
Thread Tools Display Modes
  #1   Scotteh is offline
Old l November 1st, 2007, 01:04 AM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default PHP Navigation System

In this tutorial I will be showing you how you can setup a simple php page navigation system. By “navigation system” I mean a script that allows you to move between pages without having to edit loads of files. For example, if you want to edit a link when you have loads of html pages you have to go through them all and edit all the pages. This can take hours, but with this system you can simple edit one file and all that work is done for you. Ok, let’s get on with the tutorial. First of all we need an index.php page, this will contain all the information/image you want your core site to have, by saying “core” site I mean the information/images that will be on EVERY page of your site. Note: Please do NOT include any content on this page, this will be included later on.

Once you have your index.php setup, then this is where the script gets installed into your website. Simply, find the place you want your content to be and insert the following code (If you’re using Dreamweaver make sure your in code view):
PHP Code:
<?php 
  $page 
$_GET['page'];  //Gets the (page=) from the URL
  
if($page){  
  
$site file_exists($page.'.php') ? $page.'.php' 'error.php';}
  else{
  
$site 'home.php'// Else include the default home.php file.       
  
}
  include(
$site);
  
?>
Once you have put this code in your index.php you need to setup the content files. These files contain only the content and not the core information/images. For example you will need to setup the error.php file, this will be shown if the wrong URL is entered. In the error.php file you just need the content, My error.php file contains the following:

PHP Code:
 <?php
echo('File not Found, Please try again');
?>
This file gets placed in the root location of your website. The next thing to do is to setup the home.php file; this is the file that all visitors will see when they first come to your site. So you may want to make it include an introduction and/or news. An example of this could be:

PHP Code:
 <?php
echo('Welcome to the website, We hope you enjoy your stay.');
?>
Ok, now you have your pages setup, now I think I show you how to get to them. All you need to do is type into your url: http://yourdomain.com/?page=pagename, replacing “pagename” with the name of the page you wish to visit. If you want to take this to the next level you could even use Mod_ReWrite, this could make it look like you are using html files but really you are not. This can also help with SEO.

To do this, just add the following code to a “.htaccess” file:

RewriteEngine On
RewriteRule ^/$ /?page=home [L]

That will make your links appear as the following:

Home Page = http://yourdomain.com/home.html
Error Page = http://yourdomain.com/error.html
Contact Us Page = http://yourdomain.com/contactus.html

Thank you for reading this tutorial, if you have any questions then please email me :), Thank you.
__________________
Kriip Media - Kriip.com - All you web dev needs

Last edited by Scotteh : November 7th, 2007 at 08:26 PM.

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #2   XeonSweden is offline
Old l November 3rd, 2007, 02:12 AM
XeonSweden
Newbie
 
Join Date: Mar 2005
Posts: 2
iTrader: (0)
XeonSweden is an unknown quantity at this point
Default Re: PHP Navigation System

This is a good system

Reply With Quote
  #3   Scotteh is offline
Old l November 4th, 2007, 12:41 AM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default Re: PHP Navigation System

Thanks man, glad you like :)
__________________
Kriip Media - Kriip.com - All you web dev needs

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #4   ResellerGuru is offline
Old l November 6th, 2007, 10:31 PM
ResellerGuru
Tragic Rook
 
Join Date: Dec 2006
Posts: 51
iTrader: (0)
ResellerGuru is an unknown quantity at this point
Default Re: PHP Navigation System

thanks , ive alwaysed wondered about that mod rewrite.

Reply With Quote
  #5   Kalle is offline
Old l November 7th, 2007, 07:57 PM
Kalle
UltimateLeetSpeed

 
Join Date: Dec 2004
From: Denmark Denmark
Posts: 15,562
iTrader: (0)
Kalle has a reputation beyond repute Kalle has a reputation beyond repute Kalle has a reputation beyond repute Kalle has a reputation beyond repute
Default Re: PHP Navigation System

You have a parse error in your 3rd php code, correction;

PHP Code:
<?php
echo('Welcome to the website, We hope you enjoy your stay.');
?>
__________________

Reply With Quote
  #6   Scotteh is offline
Old l November 7th, 2007, 08:26 PM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default Re: PHP Navigation System

mm vBulletin seems to have messed it up, First post edited :D Thanks kalle
__________________
Kriip Media - Kriip.com - All you web dev needs

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #7   Brecon is offline
Old l November 7th, 2007, 08:31 PM
Brecon's Avatar
Brecon
Mad Pirate - 'ARR
 
Join Date: Apr 2006
From: Wales Wales, UK
Posts: 229
iTrader: (0)
Brecon is an unknown quantity at this point
Default Re: PHP Navigation System

ok nice, i will defo use at some point!

Send a message via MSN to Brecon
Reply With Quote
  #8   Scotteh is offline
Old l November 7th, 2007, 11:22 PM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default Re: PHP Navigation System

:), hope you do, Will save a LOT of time.
__________________
Kriip Media - Kriip.com - All you web dev needs

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #9   Craddock is offline
Old l November 10th, 2007, 01:04 PM
Craddock's Avatar
Craddock
<3

 
Join Date: Oct 2005
From: England Leicesterrrr, UK
Posts: 6,623
iTrader: (12)
Craddock has a reputation beyond repute Craddock has a reputation beyond repute Craddock has a reputation beyond repute Craddock has a reputation beyond repute Craddock has a reputation beyond repute Craddock has a reputation beyond repute
Default Re: PHP Navigation System

Great Tutorial Scott.

I will indeed use it.

:)
__________________

Send a message via MSN to Craddock
Reply With Quote
  #10   Scotteh is offline
Old l November 10th, 2007, 03:38 PM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default Re: PHP Navigation System

I am not allowing you to use it haha, Joke.
__________________
Kriip Media - Kriip.com - All you web dev needs

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #11   Wau is offline
Old l November 11th, 2007, 03:58 AM
Wau
Newbie
 
Join Date: Dec 2006
Posts: 2
iTrader: (0)
Wau is an unknown quantity at this point
Default Re: PHP Navigation System

Thanks for the tutorial

Reply With Quote
  #12   Scotteh is offline
Old l November 13th, 2007, 05:56 PM
Scotteh's Avatar
Scotteh
Big Pimpin'
 
Join Date: Jun 2006
From: UK Scotish Borders
Posts: 1,440
iTrader: (1)
Scotteh is an unknown quantity at this point
Default Re: PHP Navigation System

No problemo
__________________
Kriip Media - Kriip.com - All you web dev needs

Send a message via AIM to Scotteh Send a message via MSN to Scotteh Send a message via Yahoo to Scotteh Send a message via Skype™ to Scotteh
Reply With Quote
  #13   Milezy is offline
Old l January 16th, 2008, 07:32 PM
Milezy
Newbie
 
Join Date: Jan 2008
Posts: 2
iTrader: (0)
Milezy is an unknown quantity at this point
Default Re: PHP Navigation System

Thanks, fantastic tut but the .htaccess doesn't work on my site
www.animeomnitude.com Any one know why?

Reply With Quote