利用gii生成会员信息列表管理model
这里的会员管理model生成需要填写命名空间,与前台gii生成model稍有不同。

后台会员信息管理列表效果

会员信息列表处理,把不需要显示的字段删掉
backend/views/user/index.php
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'username',
//'auth_key',
//'password_hash',
//'password_reset_token',
'email:email',
//'role',
'status'=>[
'label'=>'状态',
'attribute'=>'status',
'value' => function($model){
return ($model->status==10)?'激活':'未激活';
},
'filter'=>['0'=>'未激活','10'=>'激活'],
],
'created_at:datetime',
//'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
会员信息更新功能页面修改:
backend/views/user/_form.php页面
<div class="user-model-form"> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'status')->dropDownList(['0'=>'未激活','10'=>'激活']) ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => 'btn btn-success']) ?> </div> <?php ActiveForm::end(); ?> </div>

导航菜单高亮设置:
通过自定义菜单组件实现(在backend/widgets/sidebar/SidebarWidget.php 添加方法实现高亮)
/**
* 导航栏高亮
* Normalizes the [[items]] property to remove invisible items and activate certain items.
* @param array $items the items to be normalized.
* @param boolean $active whether there is an active child menu item.
* @return array the normalized menu items
*/
protected function normalizeItems($items, &$active)
{
foreach ($items as $i => $item) {
if (!isset($item['label'])) {
$item['label'] = '';
}
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
$items[$i]['label'] = $encodeLabel ? Html::encode($item['label']) : $item['label'];
$hasActiveChild = false;
if (isset($item['items'])) {
$items[$i]['items'] = $this->normalizeItems($item['items'], $hasActiveChild);
if (empty($items[$i]['items']) && $this->hideEmptyItems) {
unset($items[$i]['items']);
if (!isset($item['url'])) {
unset($items[$i]);
continue;
}
}
}
if (!isset($item['active'])) {
if ($this->activateParents && $hasActiveChild || $this->activateItems && $this->isItemActive($item)) {
$active = $items[$i]['active'] = true;
} else {
$items[$i]['active'] = false;
}
} elseif ($item['active']) {
$active = true;
}
if (isset($item['visible']) && !$item['visible']) {
unset($items[$i]);
continue;
}
}
return array_values($items);
}
导航栏高亮效果

