Current Menu Item

Hi guys,

I’m fairly new to PHP but I’m trying to design a simple website. I have several pages in the website, so to save time when editing the links I made a master menu (menu.html).

I used this code to call the menu navigation code in the content pages:

[php]<?php
$menu = include “menu.html”;
echo $menu;
?>[/php]

and this is what’s in my menu.html file:

<ul id="nav" class="sf-menu">
	<li><a href="../">HOME</a></li>
	<li class="current-menu-item"><a href="#">PAGES</a>
		<ul>
			<li><a href="#"><span> Page 1</span></a></li>
			<li><a href="medullana.php"><span> Page 2</span></a></li>
		</ul>
	</li>
	<li><a href="#">CONTACT</a></li>
</ul>

It works great, the only problem is with the class=“current-menu-item” (it’s a little highlight of the button if the user is on that page). How do I make it so it still shows the special effect of the current page on the button while still having a master menu?

Thank you so much.

I figured it out (with some Googling of course), I’ll try to Google harder before posting next time. Here is the solution if anyone is interested:

menu.php will contain:
[php]

<?php $active[$current] = "class=\"current-menu-item\""; ?> [/php]

and in the content pages, you put:

[php]

<?php $current = "2"; include "menu.php"; ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service