I am using phalcon framework. I want to active parent menu when children are opened in the framework terminology,
when add/edit pages are opened for example this is my menu:
/controller name/action name
Users /users
- admins /admins
->add admin page /admins/add
Sales
- managers /managers
->edit managers page /managers/edit
Inventory
So when I open add admin page i.e(website/admins/add) then users parent should be open how can I achieve that..?
Here is my nav menu page:
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav metismenu" id="side-menu" >
<li class="nav-header" >
<a href="<?=$url->get('dashboard')?>" ></a>
</li>
<?php $check_menu=array();
foreach($this->session->get("auth")['menu'] as $m):?>
<?php if (!in_array($m['parent'], $check_menu)) { ?>
<li class=>
<a href="">
<i class="fa <?=strlen($m['icon'])?$m['icon']:'fa-th-large'?>"></i>
<span class="nav-label"><?=$m['parent']?></span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level collapse">
<?php
foreach($this->session->get("auth")['menu'] as $c):?>
<?php if($c['parent']==$m['parent']):?>
<li data-open="#admin_menu" class="child_menu
<?=$c['route']==$this->router->getControllerName()."/".
$this->router->getActionName() || $c['route']==$this->router->getControllerName().
$this->router->getActionName()?" open_me":""?> ">
<a href="<?=$url->get($c['route'])?>"><?=$c['name']?></a>
</li>
<?php endif;?>
<?php endforeach;
?>
</ul>
</li>
<?php } array_push($check_menu,$m['parent']);?>
<?php endforeach;?>
</ul>
</div>
</nav>
The current functionality is working only for admins page,I want to implement "When Add admin page(admins/add) is opened at that time also Users parent should be open"
<?=$c['route']==$this->router->getControllerName()."/".$this->router->getActionName()
|| $c['route']==$this->router->getControllerName().$this->router->getActionName()
|| $c['route']==$this->router->getControllerName()?" open_me":""?> ">
I got the half solution by adding another or condition to check only the controller name.
example above is working fine only with index action BUT There is a problem:
/users/ == users/adduser || usersadduser || users
/craigslist/campaigns == craigslist/addcampaign || craigslistaddcampaign || craigslist
second case it is coming with other action in that case it is not working.so is it possible to do in this way or not.?