mirror of https://github.com/1099438829/apeblog
修正上一篇下一篇查询逻辑
This commit is contained in:
parent
a284ab8feb
commit
a4d1cc7231
|
|
@ -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 = '<?php ';
|
||||
|
||||
$parse .= '$__LIST__ =[];array_push($__LIST__,' . "tpl_get_prenext(\"$get\",$cid,\"$none\"));";
|
||||
$parse .= '$__LIST__ =[];array_push($__LIST__,' . "tpl_get_prenext(\"$get\",$cid,\"$type\"));";
|
||||
$parse .= ' ?>';
|
||||
$parse .= '{volist name="__LIST__" id="' . $void . '"}';
|
||||
$parse .= $content;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
<div class="post-turn-page-plane">
|
||||
<div class="post-turn-page post-turn-page-previous">
|
||||
<div class="post-turn-page-main">
|
||||
{ape:prenext get="pre" cid="$apeField['category_id']"}
|
||||
{ape:prenext get="pre" type="article"}
|
||||
<div>
|
||||
<a href="{:url('/article/detail')}?id={$field['id']}">{$field['title']}</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is automatically generated at:2023-09-27 17:44:20
|
||||
// This file is automatically generated at:2023-10-18 19:05:37
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\captcha\\CaptchaService',
|
||||
|
|
|
|||
Loading…
Reference in New Issue