LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2013, 09:12 AM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Question PHP navbar


Hi all,

I've got a mini-site made of three files:

header.php
index.php
footer.php

Index.php and other files include the header and footer when launched. My question is:

How do you handle the class="active" tag on the current navbar item? So if I'm on index.php, the index.php navbar button is active,.. if i go to sysinfo.php, the sysinfo.php button is active and so on.

Im not seeing a clear way to do this, because the header.php is unaware of what the actual page is.

Anyone have a good explanation for how to do this?
 
Old 09-16-2013, 09:20 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Just use of the variables to see which page got called in first place http://www.php.net/manual/de/reserve...les.server.php
 
1 members found this post helpful.
Old 09-16-2013, 03:13 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Thank you friend.

Code:
<?php
echo $_SERVER['PHP_SELF'];
?>
with a little tweaking i can get that to work.
 
Old 09-17-2013, 03:09 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Nother nice variable compound for php http://www.php.net/manual/de/languag...predefined.php.
You have to be on the lookout which one to use where. There are some pitfalls depending on how everyting is called. Be sure to check on a few more to see which variable prints out what when called in several ways.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Am trying to install packages like net-snmp, php-mysql, php-snmp, php but with errors Maj Linux - Newbie 1 07-26-2013 02:12 PM
Xara Xtreme - no Navbar drewblay Linux - Software 0 09-15-2007 04:28 PM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
NavBar and <?php require Gerardoj Programming 2 04-13-2004 02:04 PM
Konqueror Navbar 10dedfish Linux - Software 2 07-23-2003 08:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration