Example #1
0
$this->title = '文章';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="article-index">
    <?php 
/* echo $this->render('_search', ['model' => $searchModel]); */
?>

    <p>
        <?php 
echo Html::a('新建文章', ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a('采集文章管理', ['/article/gather'], ['class' => 'btn btn-primary fr']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'cover_img', 'format' => ['image', ['width' => '50']], 'value' => function ($model) {
    return $model->cover_img;
}], ['attribute' => 'title', 'label' => '文章标题', 'format' => 'html', 'value' => function ($model) {
    return '<b>' . $model->title . '</b>';
}, 'headerOptions' => ['width' => '300px']], ['attribute' => 'category_id', 'label' => '文章分类', 'value' => function ($model) {
    return \common\models\Category::get_category_result($model->category_id);
}, 'filter' => \common\models\Category::get_category()], 'author', 'publish_at', 'view_count', 'share', ['attribute' => 'status', 'value' => function ($model) {
    return $model->getStatusName($model->status);
}], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{view} {update} {delete}', 'headerOptions' => ['width' => '75']]], 'tableOptions' => ['class' => 'table table-striped table-hover']]);
?>

</div>
Example #2
0
    </p>

    <?php 
echo Html::hiddenInput('url', Yii::$app->request->getHostInfo() . Yii::$app->request->url);
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['header' => '<input type="checkbox"  id="check-all">', 'class' => yii\grid\Column::className(), 'content' => function ($model) {
    if ($model->category_id == 0) {
        return Html::checkbox('ids[]', false, ['class' => 'gather-article', 'value' => $model->id]);
    } else {
        return '';
    }
}], ['attribute' => 'id', 'value' => function ($model) {
    return $model->id;
}, 'headerOptions' => ['width' => '50px']], ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->getCategoryName();
}], ['header' => '<font style="color: #337ab7">标签</font>', 'class' => yii\grid\Column::className(), 'content' => function ($model) {
    return $model->getArticleTagToString();
}], ['attribute' => 'title', 'label' => '文章标题', 'format' => 'html', 'value' => function ($model) {
    return '<b>' . $model->title . '</b>';
}], ['attribute' => 'publish_at', 'value' => function ($model) {
    return $model->publish_at;
}, 'headerOptions' => ['width' => '100px']], ['attribute' => 'status', 'value' => function ($model) {
    return $model->getStatusName($model->status);
}, 'headerOptions' => ['width' => '100px'], 'filter' => \common\models\Article::get_status()]], 'tableOptions' => ['class' => 'table table-striped table-hover']]);
?>
    <?php 
echo Html::endForm();
?>
</div>
Example #3
0
<div class="article-index">
    <p>
        <?php 
echo Html::a('批量发布文章', ['/article/publish'], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('批量更改文章分类', ['/article/category'], ['class' => 'btn btn-primary']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'value' => function ($model) {
    return $model->id;
}, 'headerOptions' => ['width' => '50px']], ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->getCategoryName();
}], ['header' => '<font style="color: #337ab7">标签</font>', 'class' => yii\grid\Column::className(), 'content' => function ($model) {
    return $model->getArticleTagToString();
}], ['attribute' => 'title', 'label' => '文章标题', 'format' => 'html', 'value' => function ($model) {
    return '<b>' . $model->title . '</b>';
}], ['attribute' => 'publish_at', 'value' => function ($model) {
    return $model->publish_at;
}, 'headerOptions' => ['width' => '100px']], ['attribute' => 'status', 'value' => function ($model) {
    return $model->getStatusName($model->status);
}, 'headerOptions' => ['width' => '100px'], 'filter' => \common\models\Article::get_status()], ['class' => 'yii\\grid\\ActionColumn', 'header' => '<font style="color: #337ab7">操作</font>', 'template' => '{preview} {update} {delete}', 'buttons' => ['preview' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['title' => '预览']);
}], 'headerOptions' => ['width' => '75']]], 'tableOptions' => ['class' => 'table table-striped table-hover']]);
?>
    <?php 
echo Html::endForm();
?>
</div>