Example #1
0
<div class="news-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('创建信息', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
$form = ActiveForm::begin(['action' => \yii\helpers\Url::to('/Admin/news/del')]);
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'header' => Html::checkBox('selection_all', false, ['class' => 'select-on-check-all'])], 'title', ['attribute' => 'category_id', 'value' => function ($searchModel) {
    return app\models\NewsCategory::getOneCategoryNameById($searchModel->category_id);
}], ['attribute' => 'is_recommend', 'value' => function ($searchModel) {
    return app\models\NewsCategory::getIsRecommendName($searchModel->is_recommend);
}], 'create_time', 'create_user', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
    <input name="update_status" type="submit" value="删除">
    <?php 
ActiveForm::end();
?>
</div>
Example #2
0
/* @var $this yii\web\View */
/* @var $model app\models\News */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '信息发布', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="news-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('继续添加', ['create', 'category_id' => $model->category_id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('更新文章', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('删除文章', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => '确认删除吗?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', ['attribute' => 'content', 'format' => 'html', 'value' => $model->content], ['attribute' => 'category_id', 'format' => 'html', 'value' => app\models\NewsCategory::getOneCategoryNameById($model->category_id)], ['attribute' => 'status', 'value' => app\models\News::getStatusName($model->status)], ['attribute' => 'thumb', 'format' => 'html', 'value' => $model->thumb ? '<img src="/upload/images/news/thumb/' . $model->thumb . '">' : '无'], ['attribute' => 'is_recommend', 'value' => $model->is_recommend ? '是' : '否'], 'create_time', 'create_user', 'update_time', 'update_user']]);
?>

</div>