PHP Classes

File: views/backend/page/index.php

Recommend this page to a friend!
  Classes of Gabriel Alejandro López López   Yii2 Static Pages Module   views/backend/page/index.php   Download  
File: views/backend/page/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Yii2 Static Pages Module
Generate static pages for a Yii2 Web application
Author: By
Last change:
Date: 23 days ago
Size: 2,389 bytes
 

Contents

Class file image Download
<?php

use daxslab\staticpages\Module;
use
yii\helpers\Html;
use
yii\grid\GridView;
use
yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $searchModel daxslab\staticpages\backend\models\PageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$tag = 'h2';
$title = Yii::t('app', 'Sub pages');

$module = $this->context->module;
$availableLanguages = $module->languages;

if (!isset(
$parent_id)) {
   
$this->title = Yii::t('staticpages', 'Pages');
   
$this->params['breadcrumbs'][] = $this->title;

   
$tag = 'h1';
   
$title = $this->title;
}

?>
<div class="page-index">

    <header class="page-header">
        <?= Html::tag($tag, Html::encode($title)) ?>
</header>
    <?php Pjax::begin(); ?>

    <?= GridView::widget([
       
'dataProvider' => $dataProvider,
       
'filterModel' => $searchModel,
       
'columns' => [
            [
               
'class' => 'yii\grid\SerialColumn',
               
'options' => [
                   
'width' => '40px',
                ]
            ],
            [
               
'attribute' => 'language',
               
'filter' => $availableLanguages,
               
'options' => [
                   
'width' => '10%',
                ],
               
'visible' => !isset($parent_id),
            ],
            [
               
'attribute' => 'title',
               
'format' => 'raw',
               
'value' => function ($model) {
                    return
Html::a(Html::encode($model->title), ['update', 'id' => $model->id], ['data-pjax' => 0]);
                }
            ],
            [
               
'class' => 'yii\grid\ActionColumn',
               
'header' => Html::a(Html::tag('i', null, ['class' => 'fa fa-plus']),
                    [
'create', 'parent_id' => isset($parent_id) ? $parent_id : null], [
                       
'class' => 'btn btn-success',
                       
'title' => Yii::t('staticpages', 'Create Page'),
                       
'data-pjax' => true,
                    ]),
               
'template' => '{delete}',
               
'options' => [
                   
'width' => '20px',
                ],
               
'contentOptions' => [
                   
'style' => Html::cssStyleFromArray([
                       
'text-align' => 'center',
                    ]),
                ]
            ],
        ],
    ]);
?>
<?php Pjax::end(); ?>
</div>