Hello!
I'm using the helper menu to include class active
in the site menus.
Helper Menu:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if(!function_exists('active_link'))
{
function menu_ativo($controller)
{
//Obtem Instância da classe CI
$CI = get_instance();
//Obtem classe ativa.
$class = $CI->router->fetch_class();
return ($class == $controller) ? 'active' : '';
}
}
?>
And I invoke this function as below
<li class="treeview <?php echo menu_ativo('conta'); ?>">
<a href="#">
<i class="fa fa-money"></i>
<span><?php echo 'Financeiro'; ?></span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li class="<?php echo menu_ativo('categoria'); ?>">
<a href="<?php echo site_url('app/categoria'); ?>"><i class="fa fa-circle-o"></i>Categoria</a>
</li>
<li class="<?php echo menu_ativo('conta'); ?>">
<a href="<?php echo site_url('app/conta'); ?>"><i class="fa fa-circle-o"></i>Conta</a>
</li>
<li class="<?php echo menu_ativo('encargo'); ?>">
<a href="<?php echo site_url('app/encargo'); ?>"><i class="fa fa-circle-o"></i>Encargo</a>
</li>
<li class="<?php echo menu_ativo('lancamento'); ?>">
<a href="<?php echo site_url('app/lancamento'); ?>"><i class="fa fa-circle-o"></i>Lançamento</a>
</li>
</ul>
</li>
My problem is basically in <li class="treeview <?php echo " ???? " ;?>">
Since every <li>
within <ul>
belongs to a different controller, I want to activate any sub-menu and keep the main menu active <li>
.
But with the above helper not working, although the submenu is inheriting class active
, the main menu is closing.
Can you guide me?