public function actionIndex() { $query = Content::leftJoinWith('takonomy'); $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 6]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]); $locals['dataProvider'] = $dataProvider; return $this->render('index', $locals); }
/** * * @param string $where * @param string $orderBy * @param number $pageSize * @param array $options * --recommend * --headline * --sticky * --flag * --is_pic * --content_type * --page * --taxonomy:array or number * * @return array:['rows','pager'] */ public static function getPagedContents($where = null, $orderBy = null, $pageSize = 10, $options = []) { $query = self::buildContentQuery($where, $options); $query->joinWith('taxonomy', true, 'LEFT JOIN'); $page = isset($options['page']) ? $options['page'] : null; $orderBy = empty($orderBy) ? 'created_at desc' : $orderBy; $locals = LuLu::getPagedRows($query, ['page' => $page, 'pageSize' => $pageSize, 'orderBy' => $orderBy]); return $locals; }
public static function getPagedContents($where = null, $pageSize = 10) { $query = Content::leftJoinWith('taxonomy'); if (!empty($where)) { $query->andWhere($where); } $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => $pageSize]); return $locals; }
public function actionIndex() { $query = Content::leftJoinWith('takonomy'); $locals = LuLu::getPagedRows($query, [ 'orderBy' => 'created_at desc', 'pageSize' => 6 ]); return $this->render('index', $locals); }
public function actionList() { $takonomy = LuLu::getGetValue('takonomy'); $takonomyModel = Takonomy::getOneOrDefault($takonomy); $query = Content::find(); $query->where(['content_type' => $this->content_type]); $query->andFilterWhere(['takonomy_id' => $takonomy]); $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]); $locals['takonomyModel'] = $takonomyModel; return $this->render('list_default', $locals); }
/** * 列表页 * @param integer $taxonomy * @return \yii\base\string */ public function actionList($taxonomy = -1) { $query = Content::findPublished(['content_type' => $this->content_type]); if (intval($taxonomy) > 0) { $query->andFilterWhere(['taxonomy_id' => intval($taxonomy)]); } $taxonomyModel = $this->taxonomyService->getTaxonomyById($taxonomy); LuLu::setViewParam(['taxonomyModel' => $taxonomyModel]); $vars = $this->getListVars($taxonomyModel); $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => $vars['pageSize']]); $locals['taxonomyModel'] = $taxonomyModel; $this->layout = $vars['layout']; return $this->render($vars['view'], $locals); }
public function actionIndex() { $taxonomy = LuLu::getGetValue('taxonomy'); $query = Content::find(); $query->where(['content_type' => $this->content_type]); $query->andFilterWhere(['taxonomy_id' => $taxonomy]); if ($taxonomy === null) { $taxonomyModel = Taxonomy::findOne(['id' => $taxonomy]); } else { $taxonomyModel = ['id' => null, 'name' => '所有']; } $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]); $locals['taxonomyModel'] = $taxonomyModel; return $this->render('index', $locals); }