catfish Posted March 29, 2012 Report Share Posted March 29, 2012 (edited) I love php includes and use this method as much as possible, however my question is when I have built a menu that uses specific styles for the active link page I don't know how to do it. My site in question in http://www.avianorganics.com The left hand menu shows the active page is a different background color. Can someone help me with the php includes for this. Thankyou Edited September 8, 2012 by catfish Quote Link to comment Share on other sites More sharing options...
Wickham Posted March 29, 2012 Report Share Posted March 29, 2012 (edited) This page http://www.wickham43.net/highlighthome.php shows several methods. The first item is very basic and not suitable for inclusion in an "include" file. The second and third items are similar, for text links or image links, both using only CSS and a "matched pairs" coding. You put the li tags in the "include" file and put a different id or class to the ul tag or body tag on every page, so the id or class for the ul or body tag will only match one of the li tags on each page, changing its style. In the third item I deliberately coded it so that the About Us tab disappears on the About Us page, as it's not wanted for its own page, and only the other tabs show. The fourth item is using PHP. Edited March 29, 2012 by Wickham Quote Link to comment Share on other sites More sharing options...
catfish Posted April 1, 2012 Author Report Share Posted April 1, 2012 This page http://www.wickham43.net/highlighthome.php shows several methods. The first item is very basic and not suitable for inclusion in an "include" file. The second and third items are similar, for text links or image links, both using only CSS and a "matched pairs" coding. You put the li tags in the "include" file and put a different id or class to the ul tag or body tag on every page, so the id or class for the ul or body tag will only match one of the li tags on each page, changing its style. In the third item I deliberately coded it so that the About Us tab disappears on the About Us page, as it's not wanted for its own page, and only the other tabs show. The fourth item is using PHP. Thankyou, I'm going to have a look at it now... Quote Link to comment Share on other sites More sharing options...
catfish Posted September 8, 2012 Author Report Share Posted September 8, 2012 This page http://www.wickham43.net/highlighthome.php shows several methods. The first item is very basic and not suitable for inclusion in an "include" file. The second and third items are similar, for text links or image links, both using only CSS and a "matched pairs" coding. You put the li tags in the "include" file and put a different id or class to the ul tag or body tag on every page, so the id or class for the ul or body tag will only match one of the li tags on each page, changing its style. In the third item I deliberately coded it so that the About Us tab disappears on the About Us page, as it's not wanted for its own page, and only the other tabs show. The fourth item is using PHP. I'm just working on this now and I can't seem to make it work. What I am trying to get away from is editing every page each time a product is added or discontinued. What I am used to doing is using the include file so there is only 1 file to edit but the way I have been doing it I can't highlight my current page. It seems to me working through options 2 to 4 I need to place my page links on each page regardless and not just in an include page. My link again is http://www.avianorganics.com/cajun_trails.php Quote Link to comment Share on other sites More sharing options...
Andrea Posted September 8, 2012 Report Share Posted September 8, 2012 Give each page a body id - for example: <body id="indexP"> <body id="contactP"> <body id="aboutP"> in your navigation, give each item another id: <ul> <li id="index"><a href="index.php">Home</a></li> <li id="about"><a href="about.php">Photos</a></li> <li id="contact"><a href="contact.php">Contact Us</a></li> </ul> and your CSS will be like this: #indexP #index a, #aboutP #about a, #contactP #contact a { background: #aaccbc; color: #221523; } Quote Link to comment Share on other sites More sharing options...
catfish Posted September 15, 2012 Author Report Share Posted September 15, 2012 Give each page a body id - for example: <body id="indexP"> <body id="contactP"> <body id="aboutP"> in your navigation, give each item another id: <ul> <li id="index"><a href="index.php">Home</a></li> <li id="about"><a href="about.php">Photos</a></li> <li id="contact"><a href="contact.php">Contact Us</a></li> </ul> and your CSS will be like this: #indexP #index a, #aboutP #about a, #contactP #contact a { background: #aaccbc; color: #221523; } That's fantastic. Thanks so much, I've got it now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.