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

11-18-2012, 06: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 -->
<h1 class="logo"><a href="index.php"></a></h1>
<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>
<a href="portfolio.php">Portfolio</a>
<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>
<li><a href="promotions.php">Promotions</a></li>
<li><a href="contact.php">Contact</a></li>
<div class="clear"></div>

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


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

11-18-2012, 07: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><?