Jump to content

php includes


catfish

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 5 months later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...