Set Active Tab on Navigation Menu


<?php
# IM USING CODEIGNITER, EXAMPLE LINK IS: http://localhost/cenuworks/admin_user/user/1
# SNIPPET BELOW GETS CURRENT ACTIVE PAGE ID IN THIS CASE IT IS user
$seg2 = $this->uri->segment(2);
?>

the PHP code above will produce the HTML below and it will set which tab(“li”) is active


<ul>
<li><a<?php if($seg2 == '') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/">Home</a></li>
<li><a<?php if($seg2 == 'add_ce_step1') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>ae_user/add_ce_step1/">Create Cost Estimate</a></li>
<li><a<?php if($seg2 == 'user') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/user/">Users</a></li>
<li><a<?php if($seg2 == 'client') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/client/">Clients</a></li>
<li><a<?php if($seg2 == 'advertiser') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/advertiser/">Advertiser</a></li>
<li><a<?php if($seg2 == 'contacts') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/contacts/">Client/Advertiser Contacts</a></li>
<li><a<?php if($seg2 == 'ratecard') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>admin_user/ratecard/">Ratecard</a></li>
<li><a<?php if($seg2 == 'myaccount') { echo ''; } else { echo ''; } ?> href="<?php echo base_url(); ?>ae_user/myaccount/">My Account</a></li>
</ul>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s