浏览代码

!245 修复后台分类调用PID为0时无法调用顶级分类
Merge pull request !245 from simon429/master

Karson 5 年之前
父节点
当前提交
bcfbe92d51
共有 1 个文件被更改,包括 9 次插入10 次删除
  1. 9 10
      application/admin/controller/Ajax.php

+ 9 - 10
application/admin/controller/Ajax.php

@@ -220,17 +220,16 @@ class Ajax extends Backend
         $type = $this->request->get('type');
         $type = $this->request->get('type');
         $pid = $this->request->get('pid');
         $pid = $this->request->get('pid');
         $where = ['status' => 'normal'];
         $where = ['status' => 'normal'];
-        $categorylist = null;
-        if ($pid !== '') {
-            if ($type) {
-                $where['type'] = $type;
-            }
-            if ($pid) {
-                $where['pid'] = $pid;
-            }
-
-            $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select();
+        $categorylist = null;        
+        if ($pid || $pid === '0') {
+            $where['pid'] = $pid;
+        }
+        if ($type) {
+            $where['type'] = $type;
         }
         }
+        
+        $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select();
+
         $this->success('', null, $categorylist);
         $this->success('', null, $categorylist);
     }
     }