This post has been edited by catfish: 08 September 2012 - 11:12 AM
Page 1 of 1
php includes using active/current links and php includes
#1
Posted 28 March 2012 - 07:52 PM
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
#2
Posted 29 March 2012 - 12:37 AM
This page http://www.wickham43...ghlighthome.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.
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.
This post has been edited by Wickham: 29 March 2012 - 12:38 AM
#3
Posted 01 April 2012 - 11:48 AM
Wickham, on 28 March 2012 - 10:37 PM, said:
This page http://www.wickham43...ghlighthome.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.
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...
#4
Posted 08 September 2012 - 12:52 PM
Wickham, on 28 March 2012 - 10:37 PM, said:
This page http://www.wickham43...ghlighthome.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.
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.avianorga...ajun_trails.php
#5
Posted 08 September 2012 - 01:05 PM
Give each page a body id - for example:
in your navigation, give each item another id:
and your CSS will be like this:
<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; }
#6
Posted 15 September 2012 - 11:06 AM
Andrea, on 08 September 2012 - 11:05 AM, said:
Give each page a body id - for example:
in your navigation, give each item another id:
and your CSS will be like this:
<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.
Share this topic:
Page 1 of 1

Help















