I have what is probably a super basic question, but it is something I have never seemed to need to do before, and must not be using the right Key words with google.
I have a very simple menu. On the home page I don't want it to display "Home" but I do on all the other pages. Like wise I want "About Us" to display on all the pages but the About page.
So in short I need to do the following:
if not current page = "index.php" display home link;
if not current page = "about.php" display about link;
etc...
Any ideas on how to do this? I came across some examples in my google research, but they all were very complicated and lengthy for what seams should be a simple one line of code per link.
Determine the current page name?
Moderator: General Moderators
-
Johnnyjoe2000
- Forum Newbie
- Posts: 6
- Joined: Mon May 21, 2007 9:20 am
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
You could check $_SERVER['PHP_SELF'], but everyone here who's a better programmer than me will recommend against it.
A more sure way is to create a variable in every page called, like, $title, and set it to the title you want it to be. Then, check against it. Just be sure to set the variable on every page before you check.
A more sure way is to create a variable in every page called, like, $title, and set it to the title you want it to be. Then, check against it. Just be sure to set the variable on every page before you check.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I use __FILE__ or $_SERVER['SCRIPT_FILENAME'] in conjunction with basename(). I stay away from all things $_SERVER['PHP_SELF'].
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
All I ever remember you guys saying wasEverah wrote:I use __FILE__ or $_SERVER['SCRIPT_FILENAME'] in conjunction with basename(). I stay away from all things $_SERVER['PHP_SELF'].
Then, I frantically searched Google for an alternative, and finally decided to just assume that I had to specify it.Everah wrote:stay away from all things $_SERVER['PHP_SELF'].
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA