Hi guys, i want to find something out that will help me out a great deal.

I am including a menu from a separate .php file using

<?php include("menu.php"); ?>

but something that i really need to find out before i can continue with this.

When I'm at eg 'Home' then the 'Home' button should be highlighted. is there a way that with this php include, i can have a script that grabs something within each page, eg a title or a set variable or what ever, and if the content that it grabbed corresponds with the certain button, then it will highlight that button?

here is my menu's html code to show how its being higlited (NOTE: THE GALLERY IS HIGHLIGHTED AND NOT HOME IN THIS CODE)

<div class="nav">
                	<div class="l"></div>
                	<div class="r"></div>
                	<ul class="menu">
<!---------------------HOME-------------------->
                		<li style="margin-left:5px">
                			<a href="index.php"><span class="l"></span><span class="r"></span>
							<span class="t">Home</span></a>
                		</li>
                		<li>
                			<a href="gallery.php" class=" active"><span class="l"></span><span class="r"></span><span class="t">
                			Gallery</span></a>
                			<ul>
                				<li><a href="gal_catering.php">Catering</a></li>
                				<li><a href="gal_cakes.php">Cakes</a></li>
                				<li><a href="gal_confectionery.php">Confectionery</a>
                			<ul>
								<li><a href="gal_cakes.php">Cookies</a></li>
                				<li><a href="gal_baskets.php">Baskets</a></li>
                			</ul>
                			</li>
                			</ul>
                		</li>
<!------------------------------------------------>		
                		<li>
                			<a href="quote.php"><span class="l"></span><span class="r"></span>
							<span class="t">Quote</span></a>
							<ul>
                				<li><a href="quote_catering.php">Catering</a></li>
                				<li><a href="quote_confectionery.php">Confectionery</a></li>
                			</ul>
                			</li>
<!------------------------------------------------>	
							 <li>
                			<a href="blog/"><span class="l"></span><span class="r"></span>
							<span class="t">Blog</span></a></li>
<!------------------------------------------------>								
                		<li>
                			<a href="about.php"><span class="l"></span><span class="r"></span>
							<span class="t">About</span></a></li>
<!------------------------------------------------>	
                		<li>
                			<a href="contact.php"><span class="l"></span><span class="r"></span>
							<span class="t">Contact</span></a></li>
                	</ul>
                </div>

On each body tag add an id for that page, ex body id="gallery". Then on each anchor tag add an id for that link, ex: a id="gallery". In your css add body#id a#id foreach link, ex body#gallery a#gallery, body#services a#services{ css styles... }. Since each body will have a unique id and each link has a unique id the css selector will only ever be true when those conditions are met.

Thanks alot, will try it out quickly ^^ appreciate the help!

thanks that worked, i also found another way of doing it using if statements.

add to top of page

<?php 
$page = 'PAGE NAME'; 
?>

then just add to the menu.php infront of the different <li>'s

[B]<?php if ($page == 'PAGE NAME') { ?>[/B]
                		<li class="live" style="margin-left:5px">
                			<a href="index.php" class=" active"><span class="l"></span><span class="r"></span>
							<span class="t">Home</span></a>
                		</li>
                	[B]<?php } else { ?>[/B]
                		<li style="margin-left:5px">
                			<a href="index.php"><span class="l"></span><span class="r"></span>
							<span class="t">Home</span></a>
                		</li>
		        [B]<?php } ?>[/B]

that way if the $page is the same as the certain menu item, it will run the first if else it will run the second code.

Just for others who needs it ;)

but surely 210developer's way would be cleaner, this is just a simpler way for people who don't know what to do in the css template.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.