Ejemplo n.º 1
0
 /**
  * Action Tag
  * @param $id int 标签id
  */
 public function actionTag($id, $page = 1)
 {
     //获取资讯列表信息
     $pagesize = Post::PAGE_SIZE;
     $start = ($page - 1) * $pagesize;
     $mNewsMes = new Post();
     $mNewsMessage = $mNewsMes->getTagnews($id, '', $pagesize, $start);
     $count = $mNewsMes->getTagnews($id, "true");
     $totalpage = ceil($count / $pagesize);
     // $pages = new Pagination([
     //     'totalCount' => $mNewsMessage->count(),
     //     'pageSize' => Post::PAGE_SIZE
     // ]);
     // $mNewsMessage = $mNewsMessage->asArray()->all();
     // 获取首页标签信息
     $mTag = new Tag();
     $tags = $mTag->getTags();
     $condition = array('tag_id' => $id);
     $tag_name = $mTag->getTagsBycond($condition);
     $tag_result = $mTag->findOne($id);
     $tag_des = isset($tag_result->tag_des) && $tag_result->tag_des ? $tag_result->tag_des : '让我们一起发现美丽与你共创美好的生活';
     // 获取热门活动
     $mPageBlock = new PageCustomBlock();
     $slideOption['customId'] = PageCustomBlock::NEWS_PAGE_ACTIVITIES;
     $activity = $mPageBlock->block($slideOption);
     // 获取热门产品
     $mProductStat = new IProductStat();
     $HotProducts = $mProductStat->getHotProduct();
     // 获取热门文章
     $mPostStat = new PostAttrStat();
     $HotArticles = $mPostStat->getHotArticle();
     // 获取关注用户
     $mFollow = new FollowTag();
     $followUser = $mFollow->getFollowUser($id);
     $follow = ['tag_follow' => false];
     if ($user = Yii::$app->util->isLogin()) {
         // 获取用户是否喜欢/Like
         $mFollow = new Follow();
         $follow['tag_follow'] = $mFollow->getUserTagFollow($id, $user['uid']);
     }
     return $this->render('tag', ['data' => $mNewsMessage, 'tags' => $tags, 'activity' => $activity, 'products' => $HotProducts, 'article' => $HotArticles, 'tag_name' => $tag_name[0], 'tag_des' => $tag_des, 'tag_id' => $id, 'follow_user' => $followUser, 'totalpage' => $totalpage, 'follow' => $follow]);
 }