From a4d1cc7231901e85b234135c175ed91fcc716f33 Mon Sep 17 00:00:00 2001 From: yumo Date: Wed, 18 Oct 2023 19:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8A=E4=B8=80=E7=AF=87?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E7=AF=87=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/taglib/Ape.php | 4 ++-- app/index/common.php | 20 ++++++++++++------- .../template/default/pc/article/detail.html | 2 +- vendor/composer/installed.php | 4 ++-- vendor/services.php | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/common/taglib/Ape.php b/app/common/taglib/Ape.php index 43e803e..d17f2bb 100644 --- a/app/common/taglib/Ape.php +++ b/app/common/taglib/Ape.php @@ -160,10 +160,10 @@ class Ape extends TagLib $get = $tag['get'] ?? 'pre'; $cid = $tag['cid'] ?? '$cid'; $void = $tag['void'] ?? 'field'; - $none = $tag['none'] ?? '没有了'; + $type = $tag['type'] ?? 'article'; $parse = ''; $parse .= '{volist name="__LIST__" id="' . $void . '"}'; $parse .= $content; diff --git a/app/index/common.php b/app/index/common.php index 4835d7c..b5bf5fd 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -306,28 +306,34 @@ function get_document_category_all() * $get=上一篇|下一篇 * $cid=栏目分类id */ -function tpl_get_prenext($get, $cid = false, $none) +function tpl_get_prenext($get, $cid = "",$type ="article") { //文档id $id = request()->param('id'); if (!$get) { $get = 'next'; } - $document = Document::where('display', 1)->where('status', 1); + $document = Document::where('display', 1)->where('status', 1)->where('type',$type); $document = $get == 'pre' ? $document->where("id", '<', $id) : $document->where("id", '>', $id); + $document_tmp = clone $document; //如果表明在同一分类下查询 if ($cid) { $document = $document->where("category_id", $cid); } $document = $document->field('id,title')->order($get == 'pre' ? 'id desc' : 'id asc')->find(); - if ($document) { - $document['url'] = url('/article/detail?id=' . $document['id'])->build(); + $document['url'] = make_detail_url($document); } else { - $document['id'] = false; - $document['url'] = 'javascript:void(0)'; - $document['title'] = $none; + //如果执行的cid没有数据则重新请求 + $document = $document_tmp->orderRaw('rand()')->find(); + if ($document) { + $document['url'] = make_detail_url($document); + }else{ + $document['id'] = false; + $document['url'] = 'javascript:void(0)'; + $document['title'] = "暂无"; + } } return $document; } diff --git a/public/template/default/pc/article/detail.html b/public/template/default/pc/article/detail.html index 8c8720b..0e251d1 100644 --- a/public/template/default/pc/article/detail.html +++ b/public/template/default/pc/article/detail.html @@ -106,7 +106,7 @@
- {ape:prenext get="pre" cid="$apeField['category_id']"} + {ape:prenext get="pre" type="article"}
{$field['title']}
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index a015ab1..ad74967 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'topthink/think', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '903c3a4494ff2c835529904ae67939380814fbd9', + 'reference' => 'a284ab8feb3db76d633b4d2320202e59e209a9a0', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -295,7 +295,7 @@ 'topthink/think' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '903c3a4494ff2c835529904ae67939380814fbd9', + 'reference' => 'a284ab8feb3db76d633b4d2320202e59e209a9a0', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/vendor/services.php b/vendor/services.php index 56814e0..0e10d02 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\captcha\\CaptchaService',