当前位置: 首页>>代码示例>>PHP>>正文


PHP Categories::getCategoryBySlug方法代码示例

本文整理汇总了PHP中app\models\Categories::getCategoryBySlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::getCategoryBySlug方法的具体用法?PHP Categories::getCategoryBySlug怎么用?PHP Categories::getCategoryBySlug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Categories的用法示例。


在下文中一共展示了Categories::getCategoryBySlug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRssCategory

 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.');
     }
 }
开发者ID:elgorm,项目名称:yii2-blogervk,代码行数:28,代码来源:SiteController.php


注:本文中的app\models\Categories::getCategoryBySlug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。