Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->isNewRecord && $this->className() == Post::className()) {
         $this->published_at = time();
     }
     $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'updateRevision']);
     $this->on(self::EVENT_AFTER_UPDATE, [$this, 'saveTags']);
     $this->on(self::EVENT_AFTER_INSERT, [$this, 'saveTags']);
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosts()
 {
     return $this->hasMany(Post::className(), ['category_id' => 'id']);
 }
Beispiel #3
0
            <?php 
echo Html::a(Yii::t('yee', 'Add New'), ['/post/default/create'], ['class' => 'btn btn-sm btn-primary']);
?>
            <?php 
echo Html::a(Yii::t('yee/media', 'Categories'), ['/post/category/index'], ['class' => 'btn btn-sm btn-primary']);
?>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">

            <div class="row">
                <div class="col-sm-6">
                    <?php 
echo GridQuickLinks::widget(['model' => Post::className(), 'searchModel' => $searchModel, 'labels' => ['all' => Yii::t('yee', 'All'), 'active' => Yii::t('yee', 'Published'), 'inactive' => Yii::t('yee', 'Pending')]]);
?>
                </div>

                <div class="col-sm-6 text-right">
                    <?php 
echo GridPageSize::widget(['pjaxId' => 'post-grid-pjax']);
?>
                </div>
            </div>

            <?php 
Pjax::begin(['id' => 'post-grid-pjax']);
?>

            <?php 
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosts()
 {
     return $this->hasMany(Post::className(), ['id' => 'post_id'])->viaTable('{{%post_tag_post}}', ['tag_id' => 'id']);
 }
Beispiel #5
0
<?php

/* @var $this yii\web\View */
use yeesoft\comments\widgets\Comments;
use yeesoft\post\models\Post;
/* @var $post yeesoft\post\models\Post */
$this->title = $post->title;
$this->params['breadcrumbs'][] = $post->title;
?>

<?php 
echo $this->render('/items/post.php', ['post' => $post]);
?>

<?php 
if ($post->comment_status == Post::COMMENT_STATUS_OPEN) {
    ?>
    <?php 
    echo Comments::widget(['model' => Post::className(), 'model_id' => $post->id]);
}