我有 Kartik 的 SideNav ( http://demos.krajee.com/sidenav-demo/profile/default ) 通过将 url 设置为控制器/动作来正常工作,但不明白如何设置活动选项以使菜单保持不变打开并保持选择正确的菜单项。
我试过设置 'active'=> 'controller/action' (见下文)以及 'active' => 'controller/action/default#demo' 但无济于事。当我将它设置为'employee/employee-dashboard/default#demo'时,它确实会突出显示一个选项卡,但当我在这些选项卡上以相同方式执行此操作时不会更改其他选项卡。原件设置为 'active'=> 'home' 我认为这只是动作,但这对我也不起作用。
$type = SideNav::TYPE_DEFAULT;
$heading = '<i class="glyphicon glyphicon-cog"></i> Employee Menu';
$item = '/employee/employee-dashboard/default#demo';
echo SideNav::widget([
'type' => $type,
'encodeLabels' => false,
'heading' => $heading,
'items' => [
// Important: you need to specify url as 'controller/action',
// not just as 'controller' even if default action is used.
//
// NOTE: The variable `$item` is specific to this demo page that determines
// which menu item will be activated. You need to accordingly define and pass
// such variables to your view object to handle such logic in your application
// (to determine the active status).
//
['label' => 'Dashboard', 'icon' => 'home', 'url' => Url::to(['/employee/employee-dashboard', 'type'=>$type]), 'active' => ($item == '/employee/employee-dashboard/default#demo')]
['label' => 'Paycheck Info', 'icon' => 'book', 'items' => [
['label' => '<span class="pull-right badge">10</span> W2 Forms', 'url' => Url::to(['/employee/w2-form', 'type'=>$type]), 'active' => ($item == 'w2-form')],