...

View Full Version : help with menu setting "current" tab when in a function



LJackson
11-18-2012, 05:51 PM
Hi All

i have a function which includes the header info for a site i am doing, im having trouble figuring out how to set a tab as "current" as this function is called on each page.

the function is

<?php function header_info()
{?>
<!-- Header -->
<header>
<h1 class="logo"><a href="index.php"></a></h1>
<nav>
<ul class="sf-menu">
<li class="current"><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="services.php">Services</a></li>
<li>
<a href="portfolio.php">Portfolio</a>
<ul>
<li><a href="portfolio.php?gallery=hair">Hair Portfolio</a></li>
<li><a href="portfolio.php?gallery=beauty">Beauty Portfolio</a></li>
<li><a href="portfolio.php?gallery=wedding">Wedding Portfolio</a></li>
<li><a href="portfolio.php?gallery=tanning">Tanning Portfolio</a></li>
<li><a href="portfolio.php?gallery=training">Training Portfolio</a></li>
<li><a href="portfolio.php?gallery=miscellaneous">Miscellaneous Portfolio</a></li>
</ul>
</li>
<li><a href="promotions.php">Promotions</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</nav>
<div class="clear"></div>
</header>

<!-- Slider -->
<div class="mp-slider">
<ul class="items">
<li><img src="images/slide-1.jpg" alt="" /><div class="banner"><span class="row-1"></span><span class="row-2"></span></div></li>

</ul>
</div><?php
}


as you can see the class of home is set to current but as this is within a function its always set to home no matter which page your on. how can i change the class "current" depending on the pae the user is on?

many thanks

poyzn
11-18-2012, 06:27 PM
pass a parameter to the function:


<?
function header_info($gallery) {
...
?><li><a href="portfolio.php?gallery=beauty" <? if($gallery == 'beauty') echo 'class="active"'; ?>>Beauty Portfolio</a></li><?
...
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum