From 8e96995e1cc9c79a24e596953b096a620ac77ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E5=BC=BA?= <357099073@qq.com> Date: Thu, 19 Jun 2025 16:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90=E5=88=86?= =?UTF-8?q?=E7=B1=BBpages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/yunzer/menuedit.php | 136 +++++++++++++++---- app/index/controller/ResourcesController.php | 21 +-- 2 files changed, 124 insertions(+), 33 deletions(-) diff --git a/app/admin/view/yunzer/menuedit.php b/app/admin/view/yunzer/menuedit.php index 6b53a4a..3c94d40 100644 --- a/app/admin/view/yunzer/menuedit.php +++ b/app/admin/view/yunzer/menuedit.php @@ -9,13 +9,25 @@
-
- +
+ +
@@ -37,22 +49,100 @@
- + {include file="public/tail" /} \ No newline at end of file diff --git a/app/index/controller/ResourcesController.php b/app/index/controller/ResourcesController.php index 95a8655..2946474 100644 --- a/app/index/controller/ResourcesController.php +++ b/app/index/controller/ResourcesController.php @@ -38,7 +38,7 @@ class ResourcesController extends BaseController ->where('status', 1) ->order('sort', 'asc') ->select(); - + // 获取每个顶级分类下的子分类 $categories = []; foreach ($parentCategories as $parent) { @@ -46,23 +46,23 @@ class ResourcesController extends BaseController ->where('status', 1) ->order('sort', 'asc') ->select(); - + // 获取每个子分类下的资源数量 foreach ($subCategories as &$subCategory) { $subCategory['resource_count'] = Resources::where('cate', $subCategory->id) ->where('status', 1) ->count(); } - + $categories[] = [ 'parent' => $parent, 'subCategories' => $subCategories ]; } - + // 将数据传递给视图 View::assign('categories', $categories); - + return View::fetch(); } @@ -71,16 +71,16 @@ class ResourcesController extends BaseController { $cid = input('cid/d', 0); $page = input('page/d', 1); - + // 获取分类信息 $category = ResourcesCategory::where('id', $cid) ->where('status', 1) ->find(); - + if (!$category) { $this->error('分类不存在'); } - + // 获取该分类下的资源,带分页 $resources = Resources::where('cate', $cid) ->where('status', 1) @@ -90,11 +90,12 @@ class ResourcesController extends BaseController 'page' => $page, 'query' => Request::instance()->param() ]); - + // 将数据传递给视图 View::assign('category', $category); View::assign('data', $resources); - + View::assign('page', $resources->render()); // 新增这一行 + return View::fetch('list'); }