Description: In this tutorial we'll learn how to make our site navigation like index.php?page=contact.
Skill: Beginner
Time needed: 15 minutes
As stated before, some experience with html (and php) is required, since we won't be going into too much detail. You can always at any time
ask questions on our forums, send us an e-mail or use the contact form.
Right, we'll start of with the main code:
<? switch($_GET['id']) { default: include('home.php'); break; case "news": include('news.html'); break; case "contact": include('contact/contact.asp'); break; } ?>You should paste this code into your main index file, on the part where you want your content to be displayed. The next thing you should do is edit the id's and the links. On top of the code it says the following:
default: include('home.php'); break; [/code This is the default page that should be displayed. All the next bits that follow, are the id's with their associated links: [code] case "news": include('news.html'); break;As you can see, the id 'news' is linked to 'news.html'. You can name any id like you want to call it, and also any link. news.html, news.php, it
all works. Also, files which are located in sub folders can be linked. Watch the 'contact.asp' link. It's located in a folder called 'contact'. Also
this link will work. The id can be changed to whatever you like:
<? switch($_GET['id']) {The next thing you would do, is fix all your links in your menu's:
Add the following:
<a href="index.php?id=home">Home<a/>Remember, once you change the 'id' to something else, like 'page', then you will have to update your links aswell:
<a href="index.php?page=home">Home<a/>If you have for example a downloads page, you can add the main code posted above to a file called 'downloads.php'. Change 'id' to 'downloadid'
for example, and you can link like this:
<a href="index.php?page=home&downloadid=whatever">Home<a/>Just play around with it a bit, and I'm sure it will work out for you.