lulucms post模块index页面源代码
<?php
use yii\helpers\Html;
use source\core\grid\GridView;
use source\LuLu;
use source\models\Content;
use source\libs\Constants;
/* @var $this yii\web\View */
/* @var $searchModel app\models\search\ContentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$type='post';
$this->title = '文章管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->toolbars([
Html::a('新建11', ['create'], ['class' => 'btn btn-xs btn-primary mod-site-save']),
Html::a('设置', ['setting/index'], ['class' => 'btn btn-xs btn-primary mod-site-save'])
]);?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
//'filterModel' => $searchModel,
//设置布局
'layout' => "{items}\n{pager}",
'columns' => [
[
'class'=>'source\core\grid\IdColumn',
],
[
'attribute'=>'title',
'headerOptions'=>['width'=>'auto'],//headerOptions可以设置表格标题html属性.如with height等,如果修改内容是contentOptions属性
],
[
'class'=>'source\core\grid\DateTimeColumn',
'attribute' => 'updated_at',
],
//'allow_comment',
//'comments',
'userText',
'comment_count',
'view_count',
[
'attribute'=>'status',
'width'=>'25px',
'content'=>function($model,$key,$index,$gridView){
return Constants::getStatusItemsForContent($model->status);
},
],
// 'diggs',
// 'burys',
// 'sticky',
// 'password',
// 'visibility',
//'status',
// 'thumb',
//
// 'alias',
// 'excerpt',
// 'content:ntext',
// 'content_type',
// 'template',
['class' => 'source\core\grid\ActionColumn'],
],
]); ?>
IdColumn源代码
<?php
namespace source\core\grid;
class IdColumn extends DataColumn
{
public $attribute='id';
public $headerOptions=['width'=>'25px'];//设置id列宽度
//public $contentOptions=['width'=>'25000px'];
public function init()
{
parent::init();
}
}
DataColumn源代码
<?php
namespace source\core\grid;
class DataColumn extends \yii\grid\DataColumn
{
public $headerOptions = [];
public $width = '60px';
public function init()
{
parent::init();
if (! isset($this->headerOptions['width']))
{
$this->headerOptions['width'] = $this->width;
}
$this->contentOptions=['style'=>'word-wrap: break-word; word-break: break-all;'];
}
}
DateTimeColumn源代码
<?php
namespace source\core\grid;
class DateTimeColumn extends DataColumn
{
public $headerOptions=['width'=>'120px'];//这个是设置index time列宽度
public $format =['datetime', 'php:Y-m-d H:m:s'];
public function init()
{
parent::init();
}
}