Hi guys another useful code that i got from a friend ummm its about using ID's as part of the navigation, as in say you wanted to have index.php?id={pagename} (no need for the file extention on the {pagename}) and use one template of your layout in one file while the content pages can be made without great of a fuss as they will fit in your content box so its all handy dandy,
::Code::
<?php
$error = "error.php";
$news = "news/{newsfile}.{extentsion}";
if($id == "") {
include($news); }
if(isset($id)) {
if(file_exists("$id.php")) {
include("$id.php"); }
elseif(file_exists("$id.htm")) {
include("$id.htm"); } else {
include($error); } }
?>
::- Tips
- With the $news and $error you point them to the file where those files are and so if an error is when a page cannot be found the server will look for that file and show that error page,
- Files in folders - With the code it will only look for files not the DIR it lies in so you would put the code in like this in your Browser http://www.{yoursite...withoutfileext}
- Changing the id to suit your site needs, now this was quite a tricky part for me but i figured out how, now as you can see the default is ?id or $id, to change it you can change it to anything you want ,(might not suggest usieng a whole name though) and where you see the id's on the extenstion as in $ip.php (make sure you set the variable above to something like $rv and then replace all the $id's with $rv, if your really clever you can attempt adding another file extension like asp to the list,
:: Linking ::
Now this is another tricky part for those who have trouble with configuring the code to suit your needs, linking is the final stage for your visitors to see that awsome ?rv={pagename} bit on your site, so start off by grabbing your Main file with your layout, and when you add links to pages (within) the site you would code them well i do like this:
<a href="index.php?rv={pagename}">Move your mouse over me to see the ID that we want DONT CLICK you'll bring an error</a> so you would replace {pageame} with the file without the extentsion on the end, if you have done it right, you can try it out and bob is your uncle you now have a page inside your main phpfile (make sure also that incase the url goes as http://www.{yoursite}.com and does not bring up the news then add in your main file and extention like index.php and then add ?rv=newsfolder/newsfile and it will bring it up, some of the time it shouldnt have to worry as you have done it right,
There you go you awsome dudes just another help out for those who need help haha if you have questions please email them to d.dwag.nz@gmail.com and i will try and get back to you asap!
::> Easy PHP Navigation
Started by FlYiNg AcE, Jan 31 2006 08:24 PM
2 replies to this topic
#1
Posted 31 January 2006 - 08:24 PM
#2
Posted 01 February 2006 - 06:12 AM
There are ways to make even easier navigation, like with mod_rewrite
Ares - How do you want to improve YR today?
What's stopping you from migrating to Ares? We can't implement it unless you tell us!
ModEnc - C&C Modding Encyclopedia | Modders' Quote Database | Yet Another C&C Modding Forum
What's stopping you from migrating to Ares? We can't implement it unless you tell us!
ModEnc - C&C Modding Encyclopedia | Modders' Quote Database | Yet Another C&C Modding Forum
#3
Posted 19 January 2007 - 12:41 AM
i've never used that before :/
btw, i have only just reliesed my old login here, I'm FlYiNg AcE :/
btw, i have only just reliesed my old login here, I'm FlYiNg AcE :/
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users