Jump to content

Recommended Posts

Posted (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 by catfish
Posted (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 by Wickham
Posted

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...

  • 5 months later...
Posted

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

Posted

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; 	}

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...