How To Put
I am working in Yii and am suddenly stuck in this dilemma. The thing is, till this point I was using CMenu and when working with Bootstrap, I was using TbMenu. However, in this cur
Solution 1:
You could try this if you want a JS/jQuery solution:
$(function() {
var loc = window.location.href;
$('#blah li').each(function() {
var link = $(this).find('a:first').attr('href');
if(loc.indexOf(link) >= 0)
$(this).addClass('active');
});
});
Solution 2:
I'm using this class for li
items:
class="<?php echo (Yii::$app->controller->route == 'site/index') ? 'active' : '' ?>"
Also you could use Yii::$app->controller->id
for direct links.
Solution 3:
TbMenu
is inherit from CMenu
. In the current project use active
:
<?php $this->widget('bootstrap.widgets.TbNavbar', array(
'collapse'=>true,
'htmlOptions'=>array('role'=>'navigation'),
'items'=>array(
array(
'class'=>'bootstrap.widgets.TbMenu',
'items'=>array(
array(
'label'=>'Consultas',
'url'=>array('/someController/actionSomthing'),
'visible'=>Yii::app()->user->checkAccess('someController'),
'active'=>Yii::app()->controller->id=='someController'
),
),
),
),
)) ?>
Post a Comment for "How To Put