public function actionRssCategory($category = NULL) { if (Yii::$app->params['enableRss']) { if ($category) { $dataProvider = new ActiveDataProvider(['query' => PostsSearch::find()->where(['published' => 1, 'slugUrl' => $category])->orderBy('created_at DESC')->join('INNER JOIN', "{{%sources}}", "sources_id=sources.id")->join('INNER JOIN', "{{%categories}}", "categories_id=categories.id"), 'pagination' => ['pageSize' => Yii::$app->params['pageSizeRss']]]); $response = Yii::$app->getResponse(); $headers = $response->getHeaders(); $headers->set('Content-Type', 'application/rss+xml; charset=utf-8'); echo \Zelenin\yii\extensions\Rss\RssView::widget(['dataProvider' => $dataProvider, 'channel' => ['title' => Yii::$app->params['SiteName'], 'link' => Url::toRoute('/', true), 'description' => Yii::t('app', 'New Records in category {0}', [Categories::getCategoryBySlug($category)->title]), 'language' => function ($widget, \Zelenin\Feed $feed) { return Yii::$app->language; }], 'items' => ['image' => function ($model, $widget, \Zelenin\Feed $feed) { return $model->activePhotos[0]->link; }, 'title' => function ($model, $widget, \Zelenin\Feed $feed) { return empty($model->title) || is_null($model->title) || !isset($model->title) ? $model->alternativeTitle : $model->title; }, 'description' => function ($model, $widget, \Zelenin\Feed $feed) { return '<img src="' . $model->activePhotos[0]->link . '" width="100" style="margin:10px;"/><br/>' . (!empty(StringHelper::truncateWords($model->content, 25)) ? StringHelper::truncateWords($model->content, 25) : NULL); }, 'link' => function ($model, $widget, \Zelenin\Feed $feed) { return $model->urlFull; }, 'guid' => function ($model, $widget, \Zelenin\Feed $feed) { return $model->recordId . $model->updated_at; }, 'pubDate' => function ($model, $widget, \Zelenin\Feed $feed) { return Date(DATE_RSS, $model->updated_at); }]]); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }