Exemplo n.º 1
0
 public function run()
 {
     if (!$this->model || !$this->model->tags) {
         return false;
     }
     return $this->render('default', ['tags' => $this->model->getTagsArray()]);
 }
Exemplo n.º 2
0
 public function run()
 {
     $commentModel = new Comment();
     if (\Yii::$app->user->isGuest) {
         $commentModel->scenario = 'isGuest';
     }
     $commentModel->model_name = $this->model->formName();
     $commentModel->model_id = $this->model->id;
     $root = $commentModel->getRoot();
     if ($root) {
         $commentModels = $root->getChildren();
     } else {
         $commentModels = [];
     }
     return $this->render('default', ['commentModel' => $commentModel, 'model' => $this->model, 'commentModels' => $commentModels]);
 }
Exemplo n.º 3
0
 public function actionAddComment()
 {
     if (\Yii::$app->request->isAjax) {
         $model = new Comment();
         if (\Yii::$app->user->isGuest) {
             $model->scenario = 'isGuest';
         }
         $data = ['error' => true];
         if ($model->load(\Yii::$app->request->post())) {
             $parentID = \Yii::$app->request->post('parent_id');
             $root = $model->makeRootIfNotExist();
             if (!$parentID) {
                 $model->appendTo($root);
             } else {
                 $parent = Comment::find()->where(['id' => $parentID])->one();
                 $model->appendTo($parent);
             }
             $articleModel = Article::findOne($model->model_id);
             $data = ['replaces' => [['what' => '#comments', 'data' => $this->renderAjax('@app/themes/basic/modules/article/views/default/_comments', ['model' => $articleModel])]]];
         }
         return Json::encode($data);
     } else {
         throw new NotFoundHttpException(\Yii::t('app', 'Page not found'));
     }
 }
Exemplo n.º 4
0
 public function actionIndex()
 {
     $query = Article::find()->from(['t' => Article::tableName()])->joinWith(['category', 'titleImage'])->andWhere(['t.published' => 1])->groupBy('id')->orderBy('position DESC, date DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Article::PAGE_SIZE, 'pageSizeParam' => false]]);
     PageSeo::registerSeo(PageSeo::ID_HOME_PAGE);
     return $this->render('../modules/article/views/default/index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 5
0
 public function run()
 {
     $models = Article::find()->joinWith(['titleImage'])->isPublished()->orderBy('views DESC')->limit(3)->all();
     if (empty($models)) {
         return false;
     }
     return $this->render('default', ['models' => $models]);
 }
Exemplo n.º 6
0
 public function run()
 {
     $query = new TaggingQuery();
     $tags = $query->select('tags')->from(Article::tableName())->delimiter(', ')->getTags();
     if (empty($tags)) {
         return false;
     }
     return $this->render('default', ['tags' => $tags]);
 }
Exemplo n.º 7
0
 public function actionView($alias)
 {
     /** @var Article $model */
     $model = Article::find()->from(['t' => Article::tableName()])->joinWith(['titleImage', 'category'])->andWhere(['t.alias' => $alias, 't.published' => 1])->one();
     if (!$model) {
         throw new NotFoundHttpException(\Yii::t('app', 'Page not found'));
     }
     $model->views = $model->views + 1;
     $model->save(false);
     MetaTagRegister::register($model);
     if (\Yii::$app->request->isAjax) {
         return $this->renderAjax('view', ['model' => $model]);
     }
     return $this->render('view', ['model' => $model]);
 }
Exemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getArticles()
 {
     return $this->hasMany(Article::className(), ['category_id' => 'id'])->from(['t1' => Article::tableName()])->andOnCondition(['t1.published' => 1]);
 }
Exemplo n.º 9
0
<div class="widget widget-tags">
    <h4><?php 
echo Yii::t('app', 'Tags');
?>
 <span class="head-line"></span></h4>
    <div class="tagcloud">
        <?php 
echo \justinvoelker\tagging\TaggingWidget::widget(['items' => $tags, 'smallest' => 12, 'largest' => 12, 'url' => [\frontend\modules\article\models\Article::getSearchRoute()], 'urlParam' => 'query']);
?>
    </div>
</div>
Exemplo n.º 10
0
<!--Sidebar-->
<div class="col-md-3 sidebar right-sidebar">

    <!-- Search Widget -->
    <div class="widget widget-search">
        <form class="search-form" action="#" data-url="<?php 
echo \frontend\modules\article\models\Article::getSearchUrl();
?>
">
            <input type="search" placeholder="<?php 
echo Yii::t('app', 'Enter Keywords');
?>
..." />
            <button class="search-btn" type="submit"><i class="icon-search-1"></i></button>
            <a href="#"></a>
        </form>
    </div>


    <?php 
echo \frontend\widgets\popularPosts\PopularPostsWidget::widget();
?>


    <?php 
echo \frontend\widgets\tags\TagsWidget::widget();
?>

</div>
<!--End sidebar-->
Exemplo n.º 11
0
 public function actionIndex($query)
 {
     $queryData = Article::find()->from(['t' => Article::tableName()])->joinWith(['category', 'titleImage'])->andWhere(['t.published' => 1])->andWhere('t.label LIKE :query OR t.content LIKE :query OR t.tags LIKE :query', [':query' => "%{$query}%"])->groupBy('id')->orderBy('t.position DESC, t.date DESC');
     $dataProvider = new ActiveDataProvider(['query' => $queryData, 'pagination' => ['pageSize' => Article::PAGE_SIZE, 'pageSizeParam' => false]]);
     return $this->render('../default/index', ['dataProvider' => $dataProvider, 'query' => $query, 'categoryLabel' => \Yii::t('app', 'Search')]);
 }
Exemplo n.º 12
0
<?php

/**
 * @var $tags array
 */
?>
<div class="post-tags-list">
    <?php 
foreach ($tags as $tag) {
    ?>
        <a href="<?php 
    echo \frontend\modules\article\models\Article::getSearchUrl(['query' => $tag]);
    ?>
"><?php 
    echo $tag;
    ?>
</a>
    <?php 
}
?>
</div>