[PHP] Full Navigation Tutorial
Started by
sephet
, Aug 07 2005 03:18 PM
11 replies to this topic
#1
Posted 07 August 2005 - 03:18 PM
Full PHP Navigation Tutorial
Written By Ben Kippax
So your browsing away on the internet maybe looking at some articles, using some forums
and you click and affiliate button to some site. You go to look at the name of the site
and you really like the way the page address is set out and you think "Yeah, I want one
of them!"
Well, now is your chance to have one. This tutorial will teach you about php includes and
how to encorporate it into your site and customize the page addresses to your liking.
Firstly, i little info on php includes. It Works just the same as an iframe.
But when you go to a certain height, You dont have a scrollbar, besides the main one. This
means that you get an expandable website (vertically) with all the adantages of iframes.
This php navigation script will update the content when the hyperlink is clicked.
Before i show the actual code, i will show you what the link code will look like.
<a href="filename.php?id=something">Link Name</a>
You see, its actually just html code, with a php script inserted into it. Obviously you
change the filename.php to your main page name, like you would with iframes and if any of you
have used iframes before, lets consider the ?id=something part the target attribute
for use with iframes.
OK, i hope your all following still.
You can also change the "id" part of the link, keeping in mind that the script must also be edited.
I will show you how to do this later in the tutorial though.
Now, here is the script. This script goes where you want the content to go, again,
like you would an iframe!
<?php switch($id) { default: include('filename.php');
break; case "1": include('filename1.php');
break; case "2": include('filename2.php');
break; case "3": include('filename3.php');
break; case "4": include('filename4.php');
break; case "5": include('filename5.php');
break; case "6": include('filename6.php');
break; case "7": include('filename7.php');
} ?>
I will now explain what each bit of the script does.
<?php switch($id) { default: include('filename.php');
This first line of code does several things. It opens the php script, declares the switch variable.
(the "id" part which can be changed, as long as you change it in the link also.) and tells the
script what the default page is to include. In this case it is "filename.php".
This default page would commonly be either a news page or a site intro. However, its your website
you are using this for.
break; case "1": include('filename1.php');
This bit of code (the middle area) basically shows what the rest of the included files are
to be called and what their id is. Shown in the case area e.g. "1" or "2".
These can also be changed. The 1 and 2 attributes are what is used in the
link and is symbolised by the <a href="filename.php?id=something">Link Name</a>
I hope you are all still with me at this point.
} ?>
This line, the last line just closes the script.
Now, just to re-iterate.
If you want to change "id" to what you want, change the switch($id) to switch($whatever).
Numbers can be changed to words if you want.
If you have any questions regarding this tutorial please don't hesitate to PM me in the
tutorialtomb forums
hope you find the tutorial useful.
Regards,
Ben
Written By Ben Kippax
So your browsing away on the internet maybe looking at some articles, using some forums
and you click and affiliate button to some site. You go to look at the name of the site
and you really like the way the page address is set out and you think "Yeah, I want one
of them!"
Well, now is your chance to have one. This tutorial will teach you about php includes and
how to encorporate it into your site and customize the page addresses to your liking.
Firstly, i little info on php includes. It Works just the same as an iframe.
But when you go to a certain height, You dont have a scrollbar, besides the main one. This
means that you get an expandable website (vertically) with all the adantages of iframes.
This php navigation script will update the content when the hyperlink is clicked.
Before i show the actual code, i will show you what the link code will look like.
<a href="filename.php?id=something">Link Name</a>
You see, its actually just html code, with a php script inserted into it. Obviously you
change the filename.php to your main page name, like you would with iframes and if any of you
have used iframes before, lets consider the ?id=something part the target attribute
for use with iframes.
OK, i hope your all following still.
You can also change the "id" part of the link, keeping in mind that the script must also be edited.
I will show you how to do this later in the tutorial though.
Now, here is the script. This script goes where you want the content to go, again,
like you would an iframe!
<?php switch($id) { default: include('filename.php');
break; case "1": include('filename1.php');
break; case "2": include('filename2.php');
break; case "3": include('filename3.php');
break; case "4": include('filename4.php');
break; case "5": include('filename5.php');
break; case "6": include('filename6.php');
break; case "7": include('filename7.php');
} ?>
I will now explain what each bit of the script does.
<?php switch($id) { default: include('filename.php');
This first line of code does several things. It opens the php script, declares the switch variable.
(the "id" part which can be changed, as long as you change it in the link also.) and tells the
script what the default page is to include. In this case it is "filename.php".
This default page would commonly be either a news page or a site intro. However, its your website
you are using this for.
break; case "1": include('filename1.php');
This bit of code (the middle area) basically shows what the rest of the included files are
to be called and what their id is. Shown in the case area e.g. "1" or "2".
These can also be changed. The 1 and 2 attributes are what is used in the
link and is symbolised by the <a href="filename.php?id=something">Link Name</a>
I hope you are all still with me at this point.
} ?>
This line, the last line just closes the script.
Now, just to re-iterate.
If you want to change "id" to what you want, change the switch($id) to switch($whatever).
Numbers can be changed to words if you want.
If you have any questions regarding this tutorial please don't hesitate to PM me in the
tutorialtomb forums
hope you find the tutorial useful.
Regards,
Ben
#2
Posted 18 August 2005 - 06:40 AM
Nice, I should start using this
#3
Posted 22 August 2005 - 09:54 AM
I never have got these nav scripts. So i have to write all my "index" or "downloads" pages on index.php or downloads.php? Can i put all my page data for say "downloads-games" or "downloads-media" in a MySQL database and use css and php to call this up in an iframe with a specific style?
If so how can i do this?
I think PhpBB, IPB and vBulletin do this because if you open a .php page in these forums you do not find ALL of the posts made in viewtopic.php if you look at it.
Thanx
If so how can i do this?
I think PhpBB, IPB and vBulletin do this because if you open a .php page in these forums you do not find ALL of the posts made in viewtopic.php if you look at it.
Thanx
#4
Posted 22 August 2005 - 11:09 AM
phpBB uses something far more complex then what this is for. And the reason you don't see all the topics in viewtopic.php when you look at that individual file is because the files above it pass on variables, constants, functions, etc... so that it would be impossible to view anything besides an error.
Also, i don't quite get your question, could you possible re-explain it a bit better?
Also, i don't quite get your question, could you possible re-explain it a bit better?
#5
Posted 23 August 2005 - 03:50 PM
Soz
To use this scrip does all my content for each id=page have to be on say, the index page?
To use this scrip does all my content for each id=page have to be on say, the index page?
#6
Posted 25 August 2005 - 05:03 PM
yes, but it doesnt use iframes, it uses php includes, so the content area will stretch instead of making another scrollbar!
#7
Posted 01 October 2005 - 02:44 PM
What If I want to do something like this... index.php?module=downloads&id=2
#8
Posted 22 November 2005 - 02:16 AM
Well, you have to use If and ElseIf statements...It can be very confusing...And, unfortunately, I am not good at explaining how to do this. =(
#9 _*Creative Insanity_*
Posted 22 September 2007 - 11:58 AM
This is pretty awesome. I must try this one.
I have a question that has baffled me for some time.. how are the links that show in a URL bar gained that look like a set of random numbers and letters? Are these just encrypted links?
I have a question that has baffled me for some time.. how are the links that show in a URL bar gained that look like a set of random numbers and letters? Are these just encrypted links?
#10
Posted 22 September 2007 - 04:00 PM
You may be referring to a session ID, which would look like '?sid=08c5b37a01bf538d0e24df7ab9229900'. This is for passing a session to other pages should cookies not be available for saving sessions.
More information on sessions.
More information on sessions.
#11
Posted 02 October 2007 - 09:52 AM
This is all I get
well, it includes the 'default page just after that but I cant retrieve any other pages listed
heres the whole html
please help
Notice: Undefined variable: id in /home/fhlinux170/a/alexswildworld.co.uk/user/htdocs/index.php on line 12
well, it includes the 'default page just after that but I cant retrieve any other pages listed
heres the whole html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>EgoChasm</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="centercontainer"> <img border="0" src="img/logo.jpg"> <?php switch($id) { default: include('home.php'); break; case "1": include('other.php'); } ?> </div> </body> </html>
please help
#12
Posted 13 March 2008 - 06:39 AM
Improve it:
Now, rullingen, thats just a notice, just turn error_reporting off, or to none-notice-only-errors mode.
http://www.php.net/m...r-reporting.php
<?php
$x = $_GET['id'];
if(isset($x) {
switch($x) {
default: include('filename.php');
break; case "1": include('filename1.php');
break; case "2": include('filename2.php');
break; case "3": include('filename3.php');
break; case "4": include('filename4.php');
break; case "5": include('filename5.php');
break; case "6": include('filename6.php');
break; case "7": include('filename7.php');
}
}
?>
Now, rullingen, thats just a notice, just turn error_reporting off, or to none-notice-only-errors mode.
http://www.php.net/m...r-reporting.php
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users