Jul 25, 2008

Php Navigation - How to make your navigation based on php

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Php Navigation - How to make your navigation based on php

maddog39
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.
CODE

<?php
error_reporting (E_ALL ^ E_NOTICE);
if(!$page){ $page = $HTTP_GET_VARS['page']; } //You can change 'page' to whatever you want.

//Default Page
if($page == "" or $page == "index"){
include("main.php"); //You can change 'main.php' to whatever you want.
}
//Secondary Pages
if($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...
CODE

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. biggrin.gif

 

 

 


Reply

karlo
QUOTE(maddog39 @ Mar 13 2005, 04:46 AM)
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.
CODE

<?php
error_reporting (E_ALL ^ E_NOTICE);
if(!$page){ $page = $HTTP_GET_VARS['page']; } //You can change 'page' to whatever you want.

//Default Page
if($page == "" or $page == "index"){
include("main.php"); //You can change 'main.php' to whatever you want.
}
//Secondary Pages
if($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...
CODE

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. biggrin.gif
*

Or, you can just try the following:
CODE
<?php
if(isset($_GET[page])){

include($_GET[page].".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).

 

 

 


Reply

karlo
QUOTE(karlo @ Mar 13 2005, 10:49 AM)
Or, you can just try the following:
CODE
<?php
if(isset($_GET[page])){

include($_GET[page].".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).
*

OOPS! I CREATED A WRONG CODE! HERE IT IS AGAIN!

CODE
<?php
if(isset($_GET[page])){

include($_GET[page].".php");

}
?>
<!-- then put your html code here -->

Reply

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

<?php
$Page = $_GET['page'];
@include ($Page . ".php");
?>

and I didnt like it at all.

Reply

Plenoptic
This tutorial was written by me and is used on my site. http://plenopticdesign.com/index.php?id=1

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.
CODE
<?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.
CODE
   //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.
CODE
}
?>

There you have it. You now can access your pages using php. All you have to do is when you put the link type
CODE
<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.

Reply

BuffaloHELP
Merged two similar topics into one.

Please search the forum before making a new topic. You must QUOTE even if you wrote it when it's published elsewhere BEFORE posting in Trap17's forum.

Reply

Tyssen
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.

Reply

bucksta
hmm. looks decent...

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php navigation next - 18.26 hr back. (1)
  2. php switch navigation organization - 123.35 hr back. (1)
Similar Topics

Keywords : php, navigation, make, navigation, based, php

  1. Make A Flat Based Shoutbox, With Auto Refresh.
    (6)
  2. Creating Navigation For Html Websites
    Have a common navigation menu for the whole website! (12)
    Pre-requisite: HTML, inline frame tags 1 Attachment(.zip) included. Updates : 29-12-07: Doctype
    added in example files (Advised by jlhaslip) Designing a whole website takes a lot of planning
    and organization. Designing a proper navigation system is a basic step in building your website. If
    you are developing webpages in html you would have observed that as you go on creating pages it
    becomes difficult to maintain the links to the pages. This article will guide you in developing a
    common navigation menu for your website. It describes three ways, so if you don'....
  3. Background Image Swap Script
    Change a Background Image based on clock time (15)
    Background Image Changer Script To swap the background image from your CSS file according to the
    Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {
        background: url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the
    folder, place three images named morning.png, day.png, night.png. 4.) Also, in the same folder,
    create an index.php file and copy/paste the following script. CODE <?php $hour =
    date('H'); if ($hour < 12 ) {     $image =
    "morning.png"; } ....
  4. Faux Ajax Loading - Css Only
    Pretend your site is Ajax based (3)
    Link: http://www.jlhaslip.trap17.com/samples/misc/ajax/index.html Check that out. The first page
    has information and the second and has the actual example of its use with sample CSS code. I find
    that when you visit a site which has a slow server and attempt to view 'large' Image files,
    it is pretty boring to sit and stare at a blank screen, so this little snippet of code can be used
    to give the visitor something to see to indicate that the image is being downloaded. I built a
    small animated gif that sits in the background of the space allocated for the image....
  5. Making a java based program
    (3)
    Java GUI Making a Little Java Program Sec. 1: Imports and starting it off Sec. 2: Variables Sec.
    3: Frame and Stuff Sec. 4: Declaring buttons Sec. 5: Adding buttons Sec. 6: Action Listening Sec. 7:
    Using this for a learning experience Section 1 Now, let's think. What imports do we need? We
    obviously need GUI imports. We also need the action Listener. So, let's declare this at the very
    top: Code: CODE import java.awt.*; import java.awt.event.*; import javax.swing.*; That's
    all we need to get all our supplies. Now to start us off. Skip a couple lines ....
  6. Css-based "i-frames" (sort Of)
    A couple of ways to do it... (1)
    I got thinking that it might be nice to have a method to load a bunch of pictures up to a site, but
    not have them taking up a lot of space. And without using a bunch of php, while still presenting the
    entire picture. And using full-on CSS coding, not tables or frames. So here you go... a "picture in
    a picture" method. A CSS framed picture And a "hidden" "picture in a picture" method. A
    "hidden" CSS framed picture Sort of a way to 'hide the picture and let the user decide if they
    want to actually see the image. All it does is use positioning for placing the....
  7. How To Make A Simple File Based Shoutbox Using Php And Html
    (8)
    A simple tut to make a simple shoutbox. Let me jump right in. First of all you need the standard
    equipment for PHP, an IDE like XAMPP and an editor like PHP EDITOR 2OO7. Were going to make a
    simple guestbook using three files, webpage.php, shout.php and shout.txt. Webpage.php can be
    changed to whatver you want, it will be the page on which the guestbok is shown, you could even use
    this code and add it to another php page n your site. Shout.php is the proccessing page and
    shout.txt is where the shouts are stored. Firstly we need to make the visual design of the box.....
  8. Beginner's Guide To Skiing
    Based on my own experience. (4)
    I really like skiing. It is so much fun that you won't know how you could have survived until
    your first time. So here are some things you should know before you head over to your lcoal ski
    area: Dressing: You should get a few basic things: -Base layer: long underwear, especially
    thermals, keep you warm, wick moisture from the skin, keep your legs from getting irritated by your
    ski pants -Middle layer: A fleece jacket; or anything aside from wool, which is very itchy. This
    will keep you warm in cold weather. If your outer jacket or parka (see below) is insulate....
  9. Css Based Photo Gallery Code
    Fluid design for layout (3)
    Fluid Design Photo Gallery There are quite a few Topics here on the Trap17 Forum about how to
    set-up and use Photo Galleries and about the link code for getting from a Thumbnail Image to a full
    size Image and all that stuff, so I would like to take this "Photo Gallery" concept one step further
    without covering what others have already supplied instruction for. Usually, when there is a
    solution posted here for the code on "how-to-do-this", there are tables involved and the Links are
    placed inside Table cells. Tables are not neccesarilly a bad thing, but they were n....
  10. How To Setup A Php-nuke Based Site
    very helpfull (5)
    Ok, so you want to have a php nuke site. First of all, what is this "PHP nuke", and why is it so
    special? Php nuke is a web portal system. It is expandible, and can be very usefull. You can find
    an example here. Yes, it is that good. So, lets take a closer look. It's pre-packaged basic
    features are: *forums *a login system *weblinks *downloads *news *polls *faqs *content You can
    allways de-actuvate some features, but it's near-imposible to remove them. Kinda annoying, but
    you know. Some people may not need phpnuke, or cant have i period. You need: *some ....

    1. Looking for php, navigation, make, navigation, based, php

Searching Video's for php, navigation, make, navigation, based, php
advertisement



Php Navigation - How to make your navigation based on php



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE