- This topic is empty.
-
AuthorPosts
-
November 23, 2009 at 1:29 pm #26894jmiziMember
Hi,
I am using the jquery lavalamp plugin for a piece of navigation, and the plugin requires that <li> for the active page must have a class of "current"… and that is what makes it highlight the appropriate page. Thats all fine and dandy…My problem is that for my navigation, I have one php file with all my navigation that the rest of my pages link to using php insert. So just setting one <li> as current would highlight only one navigation option throughout all the pages.
What im wondering is if theres a way to have a php statement that says that "if the body id="blabla", then put "current" in li class. If not then dont do anything."
This way, for example, on the home page it will see that my body id = "home" and then insert the "current" class into the <li> tag for the home link, and that one will be highlighted on the home page. And when the body id ="about", it will highlight the about link…. etc.
Thanks so much… any help will be greatly appreciated. At least if someone can tell me if this is even possible or not.
November 23, 2009 at 1:39 pm #66947AshtonSandersParticipantThis sounds like you are working on a custom-programmed site.
Yes it’s possible, but you need to somehow tell your navigation file what page you are on.
Here’s one example I’ve done:
Code:$pg = $_SERVER['PHP_SELF']; ?>- “>about
Each If statement checks to see if $pg == the page name, and then echo’s current into the class if so.
Hope that helps.
November 23, 2009 at 1:56 pm #66949jmiziMemberthanks! … now should i put
Code:$pg = $_SERVER['PHP_SELF']; ?>in my navigation php file, or in each of my actual page files?
heres what my navigation file looks like:
Code:$pg = $_SERVER['PHP_SELF']; ?>- Home
- About
- Portfolio
- Contact
- Blog
I must be doing something wrong, because its not catching it. Here is the link to the test site:
http://mizirawi.com/justinmizirawi/index.phpThe only working links are home and about… it defaults to home. But when i go to the about page… it should highlight that link
November 23, 2009 at 2:47 pm #66952jmiziMemberAll fixed…. i just needed to put the folder name before the actual file so PHP_SELF could recognize it. Thanks for all your help AshtonSanders! :D
November 23, 2009 at 3:35 pm #66962AshtonSandersParticipantAwesome. Glad it worked.[img]http://www.websitesinaflash.com/images/thumbsup.gif[/img]
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.