예제 #1
0
 public static function getOneOrDefault($taxonomy)
 {
     $taxonomyModel = Taxonomy::findOne(['id' => $taxonomy]);
     if ($taxonomyModel === null) {
         $taxonomyModel = ['id' => null, 'name' => '所有'];
     }
     return $taxonomyModel;
 }
예제 #2
0
 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);
 }
예제 #3
0
 /**
  * Finds the Taxonomy model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Taxonomy the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Taxonomy::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }