/** * Tag action * @param $tag * @return string */ public function actionTag($tag) { Url::remember('', 'tag'); $model = new SearchContent(); $dataProvider = $model->getTagItems($tag); $this->layout = 'search-content'; return $this->render('tag', compact('model', 'dataProvider', 'tag')); }
public function actionRss() { $model = new SearchContent(); $dataProvider = $model->getItems(true); $response = Yii::$app->getResponse(); $headers = $response->getHeaders(); $headers->set('Content-Type', 'application/rss+xml; charset=utf-8'); /** @noinspection PhpUnusedParameterInspection */ $response->content = RssView::widget(['dataProvider' => $dataProvider, 'channel' => ['title' => Yii::$app->name, 'link' => Url::toRoute('/', true), 'description' => Yii::t('front', 'Articles'), 'language' => Yii::$app->language], 'items' => ['title' => function ($model, $widget) { return $model['title']; }, 'description' => function ($model, $widget) { return StringHelper::truncateWords($model['perex'], 50); }, 'link' => function ($model, $widget) { return Url::toRoute(['site/content', 'id' => $model['id']], true); }, 'guid' => function ($model, $widget) { $date = \DateTime::createFromFormat('Y-m-d H:i:s', $model['updated_at']); return Url::toRoute(['site/content', 'id' => $model['id']], true) . ' ' . $date->format(DATE_RSS); }, 'pubDate' => function ($model, $widget) { $date = \DateTime::createFromFormat('Y-m-d H:i:s', $model['updated_at']); return $date->format(DATE_RSS); }]]); }