Example #1
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">

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

    <p>
        <?php 
echo Html::a('Create Category', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'options' => ['style' => 'width: 65px; max-width: 65px;'], 'contentOptions' => ['style' => 'width: 65px; max-width: 65px;']], ['attribute' => 'parent_id', 'options' => ['style' => 'width: 75px; max-width: 75px;'], 'contentOptions' => ['style' => 'width: 75px; max-width: 75px;']], ['attribute' => 'name', 'options' => ['style' => 'min-width: 300px;'], 'contentOptions' => ['style' => 'min-width: 300px;']], ['attribute' => 'url', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    $value = $model->url;
    $html = Html::tag('span', Html::encode($value), ['class' => 'label label-blue']);
    return $value === null ? $column->grid->emptyCell : $html;
}], 'category_art', 'add_method', 'postCount', ['class' => BwActionColumn::className(), 'buttons' => ['link' => function ($url, $model) {
    $customurl = Yii::$app->params['frontendBaseUrl'] . GlobalHelper::getCategoryUrlById($model->id) . '/';
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-link"></span>', $customurl, ['title' => 'Открыть статью', 'target' => '_blank']);
}], 'template' => '{view} {update} {delete} {link}']]]);
?>

</div>
Example #2
0
    }
    $html = Html::tag('span', Html::encode($model->getStatusName()), ['class' => 'label label-' . $class]);
    return $value === null ? $column->grid->emptyCell : $html;
}], ['filter' => [0 => 'Нет', 1 => 'Да'], 'attribute' => 'category_art', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    /** @var Post $model */
    /** @var \yii\grid\DataColumn $column */
    $value = $model->{$column->attribute};
    switch ($value) {
        case 0:
            $class = 'default';
            $val = 'Нет';
            break;
        case 1:
            $class = 'success';
            $val = 'Да';
            break;
        default:
            $class = 'default';
            $val = 'Нет';
    }
    $html = Html::tag('span', Html::encode($val), ['class' => 'label label-' . $class]);
    return $value === null ? $column->grid->emptyCell : $html;
}], ['attribute' => 'views', 'label' => 'D'], ['attribute' => 'commentsCount', 'header' => '<i class="fa fa-comments"></i>'], ['class' => BwActionColumn::className(), 'buttons' => ['link' => function ($url, $model) {
    $customurl = $model->frontendLink;
    //$model->frontendLink для AR
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-link"></span>', $customurl, ['title' => 'Открыть статью', 'target' => '_blank']);
}], 'template' => '{view} {update} {delete} {link}']]]);
?>

</div>