上一篇下一篇新玩法


avatar
pcwnas 2022-10-04 212
<?php
$goPage = [
        'next'         => ['text' => '下一篇'],
        'prev'        => ['text' => '上一篇']
];
$sql = $empire->query("(SELECT titleurl, id, title FROM `{$dbtbpre}ecms_news` WHERE `id` < " . $navinfor['id'] . " AND `classid` = " . $navinfor['classid'] . " ORDER BY `id` DESC LIMIT 1) UNION (SELECT titleurl, id, title FROM `{$dbtbpre}ecms_news` WHERE `id`> " . $navinfor['id'] . " AND `classid` = " . $navinfor['classid'] . " ORDER BY `id` LIMIT 1)");
if(0 < $empire->num1($sql)) {
        while($r = $empire->fetch($sql)){
        $key = isset($r['id']) && $r['id'] > $navinfor['id'] ? 'next' : 'prev';
        $goPage[$key]['title']                 = $r['title'];
        $goPage[$key]['titleurl']         = sys_ReturnBqTitleLink($r);
        }
}
?>

内容显示模板

            <nav class="blog-pagination" aria-label="Pagination">
                <?php foreach($goPage as $type => $page):?>
                <a class="btn btn-lg<?php echo !isset($page['title']) ? ' btn-outline-secondary disabled': ' btn-outline-danger';?> me-2" href="<?php echo $page['titleurl'] ?? '';?>"><?php echo $page['text'];?></a>
                <?php endforeach;?>
            </nav>

暂无评论

当前仅支持登录后发布评论