Ejemplo n.º 1
0
use yii\grid\GridView;
use esoftslimited\blog\Module;
use esoftslimited\blog\helpers\Helper;
/* @var $this yii\web\View */
/* @var $searchModel esoftslimited\blog\models\TypeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('main', 'Post types');
$this->params['breadcrumbs'][] = ['label' => Module::t('main', 'Blog'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="type-index">

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

    <p>
        <?php 
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Module::t('main', 'New post type'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['title', 'alias', ['attribute' => 'show_category', 'format' => 'html', 'value' => function ($model) {
    return Helper::booleanIconChoiceArray()[$model->show_category];
}, 'filter' => Helper::booleanChoiceArray()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Ejemplo n.º 2
0
            <div class="col-md-5">
                <?php 
    echo $this->render('_search', ['model' => $searchModel, 'titles' => $titles]);
    ?>
            </div>
        <?php 
}
?>
    </div>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'title', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model->title, ['post/update', 'id' => $model->id]);
}], ['attribute' => 'category_id', 'value' => function ($model) {
    return !empty($model->category) ? $model->category->title : null;
}, 'filter' => Category::getList()], ['attribute' => 'type_id', 'value' => function ($model) {
    return $model->type->title;
}, 'filter' => Type::getList()], ['attribute' => 'meta_description', 'format' => 'html', 'value' => function ($model) {
    $metaDescriptionStatus = !empty($model->meta_description) ? 1 : 0;
    return Helper::booleanIconChoiceArray()[$metaDescriptionStatus];
}, 'filter' => ['yes' => Yii::t('yii', 'Yes'), 'no' => Yii::t('yii', 'No')], 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']], ['attribute' => 'views', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']], ['attribute' => 'publish_status', 'value' => function ($model) {
    return $model->getStatus();
}, 'filter' => Post::getStatuses()], ['header' => Module::t('main', 'Last changes'), 'value' => function ($model) {
    return Yii::$app->formatter->asDatetime($model->getLastChangesTimestamp());
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {delete}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $this->context->getViewPostUrl($model), ['target' => '_blank', 'title' => Module::t('main', 'View post on the site')]);
}]]]]);
?>

</div>