/** * 这里添加一个判断标准..即当有子的时候...是否显示该url * * @param array $item * the menu item to be rendered. Please refer to [[items]] to see what data might be in the item. * @return string the rendering result */ protected function renderItem($item) { if (!isset($item['url']) || $this->showParentUrl == false && isset($item["items"]) && count($item["items"]) > 0) { $template = ArrayHelper::getValue($item, 'template', $this->labelTemplate); return strtr($template, ['{label}' => $item['label']]); } $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate); return strtr($template, ['{url}' => Html::encode(Url::to($item['url'])), '{label}' => $item['label']]); }
<div class="row"> <div class="col-md-4"> <?php echo $this->render("_form", ["model" => $model, "parentId" => null]); ?> </div> <div class="col-md-8"> <div class="box box-solid"> <div class="box-body no-padding"> <?php echo GridView::widget(['layout' => "{items}", 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterPosition' => GridView::FILTER_POS_HEADER, "tableOptions" => ['class' => 'table table-hover table-striped no-margin'], "columns" => [['attribute' => 'name', "format" => "html", 'value' => function ($model, $key, $index, $column) { $params = is_array($key) ? $key : ['id' => (string) $key]; $params[0] = "update"; $value = ArrayHelper::getValue($model, $column->attribute); return Html::a($value, $params); }], 'slug', ['class' => 'hass\\base\\misc\\grid\\SwitcherColumn', 'attribute' => 'status', 'filter' => StatusEnum::listData()], ['class' => 'hass\\base\\misc\\grid\\ActionColumn']]]); ?> </div> <div class="box-footer"> <div class="box-tools pull-right"> <?php echo yii\widgets\LinkPager::widget(['pagination' => $dataProvider->pagination, 'options' => ['class' => 'pagination pagination-sm inline']]); ?> </div> </div> </div> </div> </div>
<div class="box box-solid"> <div class="box-header with-border"> <h3 class="box-title"> 评论列表 </h3> </div> <div class="box-body no-padding"> <?php echo GridView::widget(['layout' => "{items}", 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterPosition' => GridView::FILTER_POS_HEADER, "tableOptions" => ['class' => 'table table-hover table-striped no-margin'], "columns" => ['comment_id', ['attribute' => 'content', "format" => "html", 'value' => function ($model, $key, $index, $column) { $params = is_array($key) ? $key : ['id' => (string) $key]; $params[0] = "update"; $value = ArrayHelper::getValue($model, $column->attribute); return Html::a($value, $params); }], 'email', 'username', 'user_ip', ['attribute' => 'created_at', 'value' => 'createdDateTime'], ['label' => "源", 'value' => function ($model, $key, $index, $column) { return ArrayHelper::getValue($model, 'entity'); }], ['class' => 'hass\\base\\misc\\grid\\SwitcherColumn', 'attribute' => 'status', 'filter' => StatusEnum::listData()], ['class' => 'hass\\base\\misc\\grid\\ActionColumn', "template" => '{update} {delete}']]]); ?> </div> <div class="box-footer"> <div class="box-tools pull-right"> <?php echo yii\widgets\LinkPager::widget(['pagination' => $dataProvider->pagination, 'options' => ['class' => 'pagination pagination-sm inline']]); ?> </div> </div> </div>