星联网络专注帝国CMS二次功能插件开发-精品网站模板站长代码素材

  • 最近更新
  • 模板:33
  • 记录:12640|
  • 插件:52|
  • 工具:4|
  • 代码:8|
  • 评论:0

DedeCMS实现静态列表支持键盘左右翻页

前言

本文主要讲解《DedeCMS实现静态列表支持键盘左右翻页》的详细内容

DedeCMS列表页支持键盘翻上、下页功能会让用户体验翻页十分方便,SEO博客、图片站采用这样的功能将为网站带来更多的PV。开发上、下翻页功能并不复杂,结合DedeCMS,织梦58SEO整合了这个功能,并修正首页和第一页分页内容重复问题,以适合seo优化

支持键盘左右键翻页JS部分
<script type="text/javascript" src="jquery.js"></script><!--引入jquery-->
<script type="text/javascript"> $(document).ready(function(){
    var prevpage=$("#pre").attr("href");
    var nextpage=$("#next").attr("href");
    $("body").keydown(function(event){
      if(event.keyCode==37 && prevpage!=undefined) location=prevpage;
      if(event.keyCode==39 && nextpage!=undefined) location=nextpage;
    });
 }); 
</script>

控制的列表上、下页<a>标签如下

<a id="pre" href="list_1_1">上一页</a>
<a id="next" href="list_1_3">下一页</a>

但是DedeCMS默认的上、下页格式并没有单独调用的标签。下面是实现方法:

静态分页单独调用上下页链接

打开/include/arc.listview.class.php,修改静态分页列表部分(动态分页感兴趣的童鞋自己研究一下吧),找到

return $plist;
}
/**
 *  获取动态的分页列表

前面加上

$plist = '';
if(preg_match('/index/i', $listitem)) $plist .= $indexpage;
if(preg_match('/pre/i', $listitem)) $plist .= $prepage;
if(preg_match('/pageno/i', $listitem)) $plist .= $listdd;
if(preg_match('/next/i', $listitem)) $plist .= $nextpage;
if(preg_match('/end/i', $listitem)) $plist .= $endpage;
if(preg_match('/option/i', $listitem)) $plist .= $optionlist;
if(preg_match('/info/i', $listitem)) $plist .= $maininfo;

这样修改,按照自己的实际需求,可以单独调用首页链接、上一页链接、页数、下一页链接、尾页链接、分页信息等。调用方法

{dede:pagelist listitem="pre"/}
{dede:pagelist listitem="next"}
{dede:pagelist listitem="index"}
{dede:pagelist listitem="option"}
{dede:pagelist listitem="pageno"}
{dede:pagelist listitem="info"}

调用出来的HTML样式如下:

<p class="pages">
 <ul>
  <li><a href="list_3_1.html">上一页</li>
  <li class="thisclass"><a href="list_3_2.html">2</a></li>
  <li><a href="list_3_3.html">3</a></li>
  <li><a href="list_3_2.html">下一页</a></li>
  <li><a href="list_3_3.html">末页</a></li>
  <li><span class="pageinfo">共 <strong>3</strong>页<strong>11</strong>条</span></li>
 </ul>
</p>

实现键盘翻页需要绑定静态分页的上一页和下一页<a>标签的ID,默认是没有ID,打开include/arc.listview.class.php,找到

/**
 *  获取静态的分页列表

继续往下,找到

 $prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";

修改为

 $prepage.="<li><a id='pre' href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";

找到

 $nextpage.="<li><a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a></li>\r\n";

修改为

 $nextpage.="<li><a id='next' href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a></li>\r\n";

本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。

本文地址:http://www.xlkjgs.com/notes/web/8449.html

以上内容由本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

星联网络

星联网络是中国最具实战的互联网创业者的知识服务商,这里有互联网行业动态,网络推广,SEO优化,SEM优化,ESC配置,行业经验分型,互联网项目,微信营销、淘宝客赚钱、新媒体营销、京东运营、跨境电商等众多互联网营销知识分享

站长运营站长必备网站运营之道才能长久发展