public function init() { parent::init(); if ($this->categoryId) { $language_id = FrontEndHelper::getLanguageIdFromAcronym(); $web_id = FrontEndHelper::getWebIdFromTextId(\Yii::$app->request->get('web', \Yii::$app->params['defaultWeb'])); $this->viewName = 'calendarium'; $this->orderBy = 'DATE_FORMAT(content.content_date, "%m%d") ASC'; $this->withImage = true; $this->withDate = true; $sql = "( SELECT DISTINCT `content`.*\n\t\t\t\t\tFROM `content`\n\t\t\t\t\tINNER JOIN `article_category` ON article_category.article_id=content.id\n\t\t\t\t\tINNER JOIN `category` ON (category.id=article_category.category_id AND category.id=:category_id)\n\t\t\t\t\tINNER JOIN `menu_item_content` ON menu_item_content.category_id=category.id\n\t\t\t\t\tINNER JOIN `menu_item` ON menu_item.id=menu_item_content.menu_item_id\n\t\t\t\t\tINNER JOIN `menu` ON menu.id=menu_item.menu_id\n\t\t\t\t\tWHERE ((((((`content`.`content_type`=:content_type))\n\t\t\t\t\t\tAND (NOT (`content`.`id`" . ($this->articleId ? "=" . $this->articleId : " IS NULL") . ")))\n AND (`content`.`active`=TRUE)) " . (Yii::$app->user->isGuest ? " AND (`content`.`public`=TRUE))" : '') . "\n\t\t\t\t\t\tAND (`content`.`language_id`=:language_id))\n\t\t\t\t\t\tAND (`menu`.`web_id`=:web_id))\n\t\t\t\t\tORDER BY " . $this->orderBy . ($this->itemsCount ? " LIMIT " . $this->itemsCount : ""); $query = ContentRecord::findBySql($sql, [':category_id' => $this->categoryId ?: $this->categoryId, ':content_type' => ContentRecord::TYPE_ARTICLE, ':language_id' => $language_id, ':web_id' => $web_id]); $this->_items = $query->all(); $this->setMenuUrlParts(); } else { throw new InvalidParamException(\Yii::t('front', 'No required parameter given') . ' - categoryId'); } }
<?php /* @var $this yii\web\View */ /* @var $menuContent \frontend\models\MenuContent */ /* @var $category \common\models\Category */ use frontend\components\CategoryArticlesList; use frontend\utilities\FrontEndHelper; $this->title = $menuContent->title; $this->params['menuContent'] = $menuContent; $category = $menuContent->category; /** @noinspection PhpUndefinedFieldInspection */ $this->context->layout = 'page-content'; if ($category->description) { echo '<div class="description category">'; echo FrontEndHelper::parseContent($category->description); echo '</div>'; } echo CategoryArticlesList::widget(['categoryId' => $category->id, 'viewName' => 'actualities', 'itemsCount' => 20, 'wordsCount' => 50, 'withImage' => true, 'imageEdgeRatio' => 0.5, 'maxImageWidth' => 200]);
<?php /* @var $this yii\web\View */ /* @var $menuContent \frontend\models\MenuContent */ /* @var $page \common\models\Page */ use frontend\components\CategoryArticlesList; use frontend\components\InvitationsList; use frontend\utilities\FrontEndHelper; use pavlinter\display\DisplayImage; $this->title = $menuContent->title; $this->params['menuContent'] = $menuContent; $page = $menuContent->content; /** @noinspection PhpUndefinedFieldInspection */ $this->context->layout = 'page-content'; if ($page->image) { echo DisplayImage::widget(['options' => ['class' => 'responsive-img', 'title' => $menuContent->title], 'category' => 'all', 'image' => $page->image->filename]); } if ($page->perex) { echo '<div class="perex">' . $page->perex . '</div>'; } if ($page->description) { echo '<div class="description" style="margin-bottom: 2rem">'; echo FrontEndHelper::parseContent($page->description); echo '</div>'; } echo InvitationsList::widget(['categoryId' => Yii::$app->params[Yii::$app->language]['hallInvitationsCategoryId'], 'viewName' => 'invitations', 'wordsCount' => 30, 'withImage' => true, 'maxImageWidth' => 200, 'columnsCount' => 1, 'imageEdgeRatio' => 0.5, 'noMessage' => true]); echo CategoryArticlesList::widget(['categoryId' => Yii::$app->params[Yii::$app->language]['hallActualitiesCategoryId'], 'viewName' => 'actualities', 'wordsCount' => 50, 'withImage' => true, 'maxImageWidth' => 200, 'imageEdgeRatio' => 0.5, 'noMessage' => true]);
?> <?php echo $articleContent->title; ?> </h2> </div> </div> </section> <section> <div class="container"> <div class="row content"> <div class="col s12 m8"> <?php echo $content; ?> </div> <div class="col s12 m4"> <?php echo CategoryArticlesList::widget(['categoryId' => $menuContent->category->id, 'articleId' => $articleContent->id, 'itemsCount' => 5, 'title' => '<i class="material-icons right">view_headline</i>' . Yii::t('front', 'Recent articles in category')]); ?> <?php echo $this->renderFile('@frontend/themes/basic/components/_buttons.php', ['url' => Url::current([], true)]); ?> </div> </div> </div> </section> <?php $this->endContent();