Jump to content


PHP Navigation Big problems


2 replies to this topic

#1 Lyall

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 15 July 2006 - 10:47 AM

Ok I am using this code for my php navigation script:

<?
if (isset($_GET['page']) && isset($_GET['id']) && file_exists('mods/'.$_GET[id].'/'.$_GET[page].'.php')) {
include 'mods/'.$_GET[id].'/'.$_GET[page].'.php';
}
else {
echo "Page Not Found";
}
?>


And it requires me to have a mods folder on my server and then any folders and filse inside this /mods folder is included in my frame and thats how the site works.

But I have installed a news script and its all working good but when you click comments it opens in a new window and the comments file is in another directory, is there anyway I can get the comments to display in my site frame.

If you go to this url http://media.bloodyrandom.com/funkrush/ind...age=newsupdates you will see what I mean, click on view comments(3), (http://media.bloodyr...mments&newsid=1)
This is the page I need included in the frame.

I cant just include the comments because I am using the http://www.webmobo.com news script system and it uses a template system which makes things complex.

PS nobody knows about this site its currently under construction and its going to rock when it comes out so please dont go posting this link around but tell me if you like the design :-)

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 972 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 15 July 2006 - 01:20 PM

That navigation looks pretty stupid to me. That script requires that you have an id and a page set, which is just plain out dumb.
Try this one instead, it's much safer and works like a charm.

<?php
$val = $_GET['page']; // Replace page with whatever you want to use, eg ?id=page
$val .= ".php"; // Makes the filename complete so if you called ?id=index, it would be index.php it has to look for
$dirty = array("..");
$clean = array("");
$val = str_replace($dirty, $clean, $val); // Prevent people from viewing root files like your password (should work i just quikly added it without testing)
			
if (isset($_GET['page'])) { // Replace page with whatever you want to use, eg ?id=page
if (file_exists($val)) { // This checks if the file you are trying to call exists
include "$val";
}
else {
include "404.php"; // If the file doesnt exists it calls your 404 error page
}
}
else {
include "home.php"; // If ?page= is not set it will now go to your news page
}
	
// Include this script in your content area
// Run ?page=pagename (without .php) to view a page
?>
*Note that I did not write this script, I've just been using it.

Now you can simply use this URL to link to that comments page.
http://media.bloodyrandom.com/funkrush/ind...ts&newsid=2
Or atleast logically you should be able to.

Edited by Demonslay, 15 July 2006 - 01:21 PM.


#3 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 15 July 2006 - 01:36 PM

Holey crap, what is it today, post code from zulumonkey day? Both those originate from there lol.

For the record, Lyalls version is better, if he didnt want the 2 variables just take one out, not use your code Demonslay, there is no need + the original is better.

I'll leave my mesage there as 1, i dont understand what this has to do with how you include files, and 2, what the problem is as you say your news posting system has a templating system? Use it? lol :)

I dunno, maybe im just tired....

Edited by .Matt, 15 July 2006 - 01:37 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users