导航栏
<?php use yii\helpers\Url; /** * $navbar说明 * label:显示的标签 * url:跳转地址 * action:判断激活的操作 * class:原始样式 * disabled:反选时被禁用 */ $navbar = [ [ 'label' => '学校管理', 'url' => Url::toRoute(['/setting-manage/school']), 'action' => ['setting-manage/school'], 'class' => '', 'disabled' => '' ], [ 'label' => '分类管理', 'url' => Url::toRoute(['/setting-manage/community-type']), 'action' => ['setting-manage/community-type'], 'class' => '', 'disabled' => '' ], [ 'label' => '管理日志', 'url' => Url::toRoute(['/setting-manage/manager-logs']), 'action' => ['setting-manage/manager-logs'], 'class' => '', 'disabled' => '' ], ]; ?> <nav class="navbar-default"> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <?php foreach($navbar as $row): ?> <li class="<?= in_array($this->context->uniqueId,$row['action'])?'active ':$row['disabled'] ?>"> <a href="<?=$row['url']?>" target=""><?=$row['label']?></a> </li> <?php endforeach; ?> </ul> </div> </nav>