Jump to content
xisto Community
Sign in to follow this  
maddog39

Php Navigation How to make your navigation based on php

Recommended Posts

I have re-constructed my last PHP Navigation system and it works great. So I have it here for you guys. Here are the instructions.

INSTRUCTIONS:
Open your main page for your site in your text editor and paste in the following code where the main content goes.

<?phperror_reporting (E_ALL ^ E_NOTICE);if(!$page){ $page = $HTTP_GET_VARS['page']; } //You can change 'page' to whatever you want.//Default Pageif($page == "" or $page == "index"){	include("main.php"); //You can change 'main.php' to whatever you want.}//Secondary Pagesif($page == "something") {  //Change 'something to what you want.        include("something.php");  //Change 'something.php' to the page your including.}if($page == "something") {        include("something.php"); //^Follow Above^//}if($page == "something") {        include("something.php"); //^Follow Above^//?>
Also when your doing this, take any other content in the main content box and put it into another file, probably main.php since that is set default but you may change that. You can also add pages by adding another...
if($page == "something") {        include("something.php");}
under the existing pages in that php block.

Then save the page to your server and make sure that all other pages of your site are plain text or just dont have the site template in them. Also make sure that your index page has an ending of '.php' or this will not work.

When changing the URLs your pages will now be accessed by 'index.php?page=something' but obiously change 'something' and the 'page' to page names you put in the php code. Got it?

Well thats about it and if you need any help just ask me. :angry:

Share this post


Link to post
Share on other sites

I have re-constructed my last PHP Navigation system and it works great. So I have it here for you guys. Here are the instructions.

 

INSTRUCTIONS:

Open your main page for your site in your text editor and paste in the following code where the main content goes.

<?phperror_reporting (E_ALL ^ E_NOTICE);if(!$page){ $page = $HTTP_GET_VARS['page']; } //You can change 'page' to whatever you want.//Default Pageif($page == "" or $page == "index"){	include("main.php"); //You can change 'main.php' to whatever you want.}//Secondary Pagesif($page == "something") { ?//Change 'something to what you want. ? ? ? ?include("something.php"); ?//Change 'something.php' to the page your including.}if($page == "something") { ? ? ? ?include("something.php"); //^Follow Above^//}if($page == "something") { ? ? ? ?include("something.php"); //^Follow Above^//?>
Also when your doing this, take any other content in the main content box and put it into another file, probably main.php since that is set default but you may change that. You can also add pages by adding another...

if($page == "something") { ? ? ? ?include("something.php");}
under the existing pages in that php block.

 

Then save the page to your server and make sure that all other pages of your site are plain text or just dont have the site template in them. Also make sure that your index page has an ending of '.php' or this will not work.

 

When changing the URLs your pages will now be accessed by 'index.php?page=something' but obiously change 'something' and the 'page' to page names you put  in the php code. Got it?

 

Well thats about it and if you need any help just ask me. :angry:

59168[/snapback]59168[/snapback]

Or, you can just try the following:

<?phpif(isset($_GET

)){include($_GET

.".php");}<!-- then put your html code here -->?>
So, if the file requested on the "page" dosen't exists, it will just ignore it and outputs the default page or the main page (the one on the bottom of the script).

Share this post


Link to post
Share on other sites

Or, you can just try the following:

<?phpif(isset($_GET
So, if the file requested on the "page" dosen't exists, it will just ignore it and outputs the default page or the main page (the one on the bottom of the script).

59256[/snapback]59256[/snapback]


)){include($_GET

.".php");}<!-- then put your html code here -->?>
OOPS! I CREATED A WRONG CODE! HERE IT IS AGAIN!

 

<?phpif(isset($_GET

)){include($_GET

.".php");}?><!-- then put your html code here -->

Share this post


Link to post
Share on other sites

Ahhh I dont like that way. I used something similar before....

<?php$Page = $_GET['page'];@include ($Page . ".php");?>
and I didnt like it at all.

Share this post


Link to post
Share on other sites

This tutorial was written by me and is used on my site. http://forums.xisto.com/no_longer_exists/

 

This tutorial will teach you how to make a navigation system using php. So instead of having your url to your affiliates page like this http://yourdomain.com/affiliates.htm it will be like this http://yourdomain.com/index.php?id=affiliates This is a better way than to use iframes, it is more efficient. So let's get started.

We will start with this code here.

<?php switch ($HTTP_GET_VARS[id])    {    //Default - case    case 'content':    default:    include 'content.htm';    break;
The switch tells you that all of the content won't be in there at once. HTTP_GET_VARS tells it to get these when called. This first one is the default one seen when you first enter the page. [id] is the case, meaning that it will be index.php?id=whatever You can change that to whatever you would like. So if you were to change it to [content] then it would be index.php?content=whatever. Put whatever file name you would like after the include, that is the file that will show up in the content area.

The next part of the code will be this.

   //Resources - case    case 'resources':    include 'resources.htm';    break;    //About Us - case    case 'aboutus':    include 'about.htm';    break;
This is the other pages you would like to be in your content area. These you have to call up which will be explained later. You won't be able to see these until you go to the link. Now to close the code put this in.

}?>
There you have it. You now can access your pages using php. All you have to do is when you put the link type
<a href="index.php?id=whatever" ?>
This whatever will be replaced on whatever you put in where it says case 'aboutus': Make sure to save your page as .php if it is not already. I hope this tutorial has helped.

 

Notice from KuBi:
Edit as per requested.
Edited by KuBi (see edit history)

Share this post


Link to post
Share on other sites

Instead of http://yourdomain.com/index.php?id=affiliates, you can do this instead: http://yourdomain.com/?id=affiliates. It looks neater.
I actually prefer Karlo's method. With the switch method, you have to write out a line for every possibility, whereas if the include has the same name as the querystring value, you just need one line of code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.