if($category){ $cate = Category::find()->where(['parentid'=>$category[0]->id])->orderBy('weights asc')->all();//$category[0]->id这个是当前默认的二级栏目,查出所有三级栏目 if(!empty($title)){//看二级栏目或三级栏目有没有选中,如果有就搜索出相关文章 $article1 = Article::find()->where(['category_name'=>$title])->andWhere(['and',['status'=>'已发布','deleted'=>'否']])->limit(10)->orderBy(['top'=>SORT_DESC,'weights'=>SORT_DESC ,'created'=>SORT_DESC])->all(); if(!empty($article1)){//选中的二级栏目或三级栏目有文章,有就输出文章 $article = $article1; $name = $title; }else{//选中的二级栏目或三级栏目没有文章,如果是选中是二级栏目就去找三级栏目的文章,如果三级栏目没有文章或选中的三级栏目没有文章就输出没有数据 $cate1 = Category::find()->where(['title'=>$title])->one(); $cate2 = Category::find()->where(['parentid'=>$cate1->id])->orderBy('id asc')->one();//查找二级栏目下所属第一个三级栏目 if(!empty($cate2)){//选中的是二级栏目,存在三级栏目 $article2 = Article::find()->where(['category_name'=>$cate2->title])->andWhere(['and',['status'=>'已发布','deleted'=>'否']])->limit(10)->orderBy(['top'=>SORT_DESC,'weights'=>SORT_DESC ,'created'=>SORT_DESC])->all(); if(!empty($article2)){//三级栏目有文章 $article = $article2; $name = $cate2->title; }else{//三级栏目没有文章 $article = ''; $name = title; }
$article1 = Article::find()->where(['category_name'=>$title])->andWhere(['and',['status'=>'已发布','deleted'=>'否']])->limit(10)->orderBy(['top'=>SORT_DESC,'weights'=>SORT_DESC ,'created'=>SORT_DESC])->all(); if(!empty($article1)){//选中的二级栏目或三级栏目有文章,有就输出文章 $article = $article1; $name = $title; }else{//选中的二级栏目或三级栏目没有文章,如果是选中是二级栏目就去找三级栏目的文章,如果三级栏目没有文章或选中的三级栏目没有文章就输出没有数据 $cate1 = Category::find()->where(['title'=>$title])->one(); $cate2 = Category::find()->where(['parentid'=>$cate1->id])->orderBy('id asc')->one();//查找二级栏目下所属第一个三级栏目 if(!empty($cate2)){//选中的是二级栏目,存在三级栏目 $article2 = Article::find()->where(['category_name'=>$cate2->title])->andWhere(['and',['status'=>'已发布','deleted'=>'否']])->limit(10)->orderBy(['top'=>SORT_DESC,'weights'=>SORT_DESC ,'created'=>SORT_DESC])->all(); if(!empty($article2)){//三级栏目有文章 $article = $article2; $name = $cate2->title; }else{//三级栏目没有文章
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; } else {
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
$config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); (new yii\web\Application($config))->run();
$_GET = [ 'title' => 'HemoPOC®凝血检测', 'type' => 'academic', ]; $_SESSION = [ '__flash' => [], ];