我正在使用phalcon框架。 我希望在框架术语中打开子项时激活父菜单,
当打开添加/编辑页面时,例如这是我的菜单:
/controller name/action name
Users /users
- admins /admins
->add admin page /admins/add
Sales
- managers /managers
->edit managers page /managers/edit
Inventory
所以当我打开添加管理页面,即(网站/管理员/添加)时,用户父母应该是开放的,我该如何实现呢?
这是我的导航菜单页面:
<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>
当前功能仅适用于管理员页面,我想实现“当添加管理页面(admins / add)时,此时也打开用户父级”
答案 0 :(得分:0)
<?=$c['route']==$this->router->getControllerName()."/".$this->router->getActionName()
|| $c['route']==$this->router->getControllerName().$this->router->getActionName()
|| $c['route']==$this->router->getControllerName()?" open_me":""?> ">
通过添加另一个或条件来检查控制器名称,我得到了一半解决方案。
以上示例仅适用于索引操作BUT 有一个问题:
/users/ == users/adduser || usersadduser || users
/craigslist/campaigns == craigslist/addcampaign || craigslistaddcampaign || craigslist
第二种情况是它正在进行其他行动,在这种情况下它不起作用。是否可以这样做。?