|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
帝国CMS原生PHP实现上一篇下一篇,没有上一篇或者下一篇的时候返回当前栏目名称和链接。
按ID排序:- <?php
- /*
- * $PreNext['prev'] // 上一篇
- * $PreNext['next'] // 下一篇
- */
- $PreNext = [];
- // 上一篇
- $pre_r = $empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_{$class_r[$GLOBALS['navclassid']]['tbname']} where id<{$navinfor['id']} and classid='{$GLOBALS['navclassid']}' order by id DESC limit 1");
- if(empty($pre_r['id'])){
- $PreNext['prev'] = '<a href="' . sys_ReturnBqClassUrl($class_r[$GLOBALS['navclassid']]) . '" title="'. $class_r[$GLOBALS['navclassid']]['classname'] . '" rel="category tag">'. $class_r[$GLOBALS['navclassid']]['classname'] . '</a>';
- }else{
- $PreNext['prev'] = '<a href="' . sys_ReturnBqTitleLink($pre_r) . '" title="' . $pre_r['title'] . '" rel="prev">' . $pre_r['title'] . '</a>';
- }
- // 下一篇
- $next_r = $empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_{$class_r[$GLOBALS['navclassid']]['tbname']} where id>{$navinfor['id']} and classid='{$GLOBALS['navclassid']}' order by id limit 1");
- if(empty($next_r['id'])){
- $PreNext['next'] = '<a href="' . sys_ReturnBqClassUrl($class_r[$GLOBALS['navclassid']]) . '" title="'. $class_r[$GLOBALS['navclassid']]['classname'] . '" rel="category tag">'. $class_r[$GLOBALS['navclassid']]['classname'] . '</a>';
- }else{
- $PreNext['next'] = '<a href="' . sys_ReturnBqTitleLink($next_r) . '" title="' . $next_r['title'] . '" rel="next">' . $next_r['title'] . '</a>';
- }
- ?>
- 上一篇:<?=$PreNext['prev']?><br >
- 下一篇:<?=$PreNext['next']?>
复制代码
按发布时间newstime排序:- <?php
- /*
- * $PreNext['prev'] // 上一篇
- * $PreNext['next'] // 下一篇
- */
- $PreNext = [];
- // 上一篇
- $pre_r = $empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_{$class_r[$GLOBALS['navclassid']]['tbname']} where newstime<{$navinfor['newstime']} and classid='{$GLOBALS['navclassid']}' order by newstime DESC limit 1");
- if(empty($pre_r['id'])){
- $PreNext['prev'] = '<a href="' . sys_ReturnBqClassUrl($class_r[$GLOBALS['navclassid']]) . '" title="'. $class_r[$GLOBALS['navclassid']]['classname'] . '" rel="category tag">'. $class_r[$GLOBALS['navclassid']]['classname'] . '</a>';
- }else{
- $PreNext['prev'] = '<a href="' . sys_ReturnBqTitleLink($pre_r) . '" title="' . $pre_r['title'] . '" rel="prev">' . $pre_r['title'] . '</a>';
- }
- // 下一篇
- $next_r = $empire->fetch1("select isurl,titleurl,classid,id,title from {$dbtbpre}ecms_{$class_r[$GLOBALS['navclassid']]['tbname']} where newstime>{$navinfor['newstime']} and classid='{$GLOBALS['navclassid']}' order by newstime limit 1");
- if(empty($next_r['id'])){
- $PreNext['next'] = '<a href="' . sys_ReturnBqClassUrl($class_r[$GLOBALS['navclassid']]) . '" title="'. $class_r[$GLOBALS['navclassid']]['classname'] . '" rel="category tag">'. $class_r[$GLOBALS['navclassid']]['classname'] . '</a>';
- }else{
- $PreNext['next'] = '<a href="' . sys_ReturnBqTitleLink($next_r) . '" title="' . $next_r['title'] . '" rel="next">' . $next_r['title'] . '</a>';
- }
- ?>
- 上一篇:<?=$PreNext['prev']?><br >
- 下一篇:<?=$PreNext['next']?>
复制代码
以上是DEMO代码,样式自己根据需求的样式修改html即可。
|
|