Welcome Guest, Not a member yet? Register   Sign In
Active tab
#1

[eluser]Unknown[/eluser]
I'm new to CodeIgniter/MVC.

I have a simple site, 3 controllers - home.php, services.php, work.php and the corresponding views - home_view.php, services_view.php, work_view.php.

Each view has navigation to each other - How would I go about creating an active tab, when on a certain view? would you set this up in the controller or the view?
#2

[eluser]Ayeyermaw[/eluser]
Personally I'd set something like this in the controller
Code:
$data['tab_index']= n
where n is whatever you need to manipulate the tab in your viewer.
This assumes that $data is the name of the array you're passing into the viewer.
#3

[eluser]Bart v B[/eluser]
That can be very easy in your view:

Code:
<?php
if($this->uri->segment(1) == 'home' or $this->uri->segment(1) == '')
{
  echo '<li class="active"><a href="'.base_url().'">Home</a></li>';            
}
else
{
  echo '<li><a href="'.base_url().'">Home</a></li>';
}
if($this->uri->segment(1) == 'services')
{
  echo '<li class="active"><a href="'.base_url().'services/">services</a></li>';            
}
else
{
  echo '<li><a href="'.base_url().'services/">services</a></li>';
}
if($this->uri->segment(1) == 'work')
{
  echo '<li class="active"><a href="'.base_url().'work/">work</a></li>';            
}
else
{
  echo '<li><a href="'.base_url().'work/">work</a></li>';
}
?&gt;
#4

[eluser]Unknown[/eluser]
Thanks Bart v B that was very helpful Smile
#5

[eluser]xerobytez[/eluser]
To get the current controller name I always use.

Code:
$this->router->class

Or to get the current function\method.

Code:
$this->router->method
#6

[eluser]Unknown[/eluser]
Thanks to all the information it's very helpful,,
i learn a lot Smile

Appreaciated
Carla
<a href="http://how-to-kiss-a-girl.org/">How To Kiss A Girl</a>




Theme © iAndrew 2016 - Forum software by © MyBB