示例#1
0
use yii\helpers\Html;
use yii\grid\GridView;
use kartik\date\DatePicker;
use app\models\Posts;
/* @var $this yii\web\View */
/* @var $searchModel app\models\PostsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Posts';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="posts-index">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <p>
        <?php 
echo Html::a('Create Post', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'text', 'value' => function ($data) {
    return Posts::getPreviewText($data->text);
}], ['attribute' => 'date', 'value' => function ($data) {
    return date('d-M-Y', $data->date);
}, 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'date_from', 'attribute2' => 'date_to', 'options' => ['placeholder' => 'Start date'], 'options2' => ['placeholder' => 'End date'], 'type' => DatePicker::TYPE_RANGE, 'pluginOptions' => ['format' => 'dd-mm-yyyy', 'autoclose' => true]])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
示例#2
0
                        <img src="<?php 
    echo Url::to('@web/img/news_item.png');
    ?>
" alt="">
                        <div class="news-text">
                            <a href="<?php 
    echo Url::to(['posts/view', 'id' => $postItem->id]);
    ?>
" >
                                <h4><?php 
    echo $postItem->title;
    ?>
</h4>
                            </a>
                            <p><?php 
    echo Posts::getPreviewText($postItem->text);
    ?>
</p>
                        </div>
                        <div class="news-date"><?php 
    echo date('d.m.Y', $postItem->date);
    ?>
</div>
                        <div class="rud-links">
                            <a href="<?php 
    echo Url::to(['posts/view', 'id' => $postItem->id]);
    ?>
" >View</a>
                            <a href="<?php 
    echo Url::to(['posts/update', 'id' => $postItem->id]);
    ?>