public function actionCat($slug, $tag = null)
 {
     $cat = Article::cat($slug);
     if (!$cat) {
         throw new \yii\web\NotFoundHttpException('Article category not found.');
     }
     return $this->render('cat', ['cat' => $cat, 'items' => $cat->items(['tags' => $tag, 'pagination' => ['pageSize' => 2]])]);
 }
Example #2
0
 public function actionArticle()
 {
     if (Yii::$app->request->get('slug')) {
         return $this->render('article-item', ['slug' => Yii::$app->request->get('slug')]);
     }
     if (Yii::$app->request->get('category')) {
         $category = Article::cat(Yii::$app->request->get('category'));
     } else {
         $category = Article::cat();
     }
     $menuItems = [];
     foreach ($category->model->getBehavior('tree')->parents(1)->one()->children(1)->all() as $item) {
         $menuItems[] = ['label' => $item->title, 'url' => ['site/article', 'category' => $item->slug]];
     }
     return $this->render('article-category', ['category' => $category, 'menuItems' => $menuItems]);
     return $this->render('article-category');
 }
Example #3
0
<?php

use yii\easyii\modules\article\api\Article;
$article = Article::get($slug);
$category = Article::cat($article->cat->slug);
?>

<div class="container content-page">
    <div class="row">
        <div class="col col-3 left-col">

            <?php 
$items = [];
foreach ($category->items() as $item) {
    $items[] = ['label' => $item->title, 'url' => ['site/article', 'slug' => $item->slug]];
}
?>
            <?php 
echo \yii\widgets\Menu::widget(['items' => $items, 'options' => ['id' => 'left-menu']]);
?>
        </div>
        <div class="col col-7 right-col">
            <h1><?php 
echo $article->title;
?>
</h1>

            <div class="content">
                <?php 
echo $article->text;
?>
Example #4
0
 public function actionWhite_label()
 {
     $page = Page::get('page-white-label');
     $cat = Article::cat('white-label');
     if (!$cat) {
         throw new \yii\web\NotFoundHttpException('Page not found.');
     }
     return $this->render('white_label', ['page' => $page, 'cat' => $cat, 'label_items' => $cat->items()]);
 }