推荐学习:织梦cms
1、为了实现这个功能,我们首先需要获得图片页面的当前页码和总页码
编辑include/inc_archives_view.PHP文件
(1)找到function ParseDMFields,修改为:
function ParseDMFields($pageNo,$ismake=1) { $this->NowPage = $pageNo; //获得当前页面编号 $this->Fields['cpagenum'] = $this->NowPage; if($this->SplitPageField!="" && isset($this->Fields[$this->SplitPageField])) { $this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1]; }
$this->Fields['cpagenum'] = $this->NowPage;
(2)找到function __construct构造函数,修改为:
$this->TotalPage = count($this->SplitFields); } //获得当前页面总数 $this->Fields['totalpage'] = $this->TotalPage; $this->LoadTemplet(); $this->ParseTempletsFirst(); }
$this->Fields['totalpage'] = $this->TotalPage;
2、接下来在模板中用js实现分析静态页面和动态页面以及向下翻页
编辑article_image.htm或者你的图集最终显示的模板,增加如下js代码:
<script language="javascript"> var npage = {dede:field/}; var totalpage = {dede:field/}; var filename=""; var curl=location.href; function goNextPic(){ str1 = /\.html/ig; str2 = /_/ig; r = curl.search(str1); r1 = curl.search(str2); if(r>0){ if(npage==1) filename = curl.substr(0,r); else filename = curl.substr(0,r1); if(npage==totalpage){ location.href = filename+".html"; } else{ location.href = filename+"_"+(npage+1)+".html"; } }else{ if(npage==totalpage){ location.href = "view.PHP?aid={dede:field/}"; } else{ location.href = "view.PHP?aid={dede:field/}&pageno="+(npage+1); } } } </script>
在这个js脚本中,我们定义一个方法goNextPic用来切换到下一个图片。
修改include/inc_channel_unit.PHP
找到”//全部列出式或分页式图集”的部分。
$revalue = "<center><a href='$src' target='_blank'><img src='$src' $iw/></a><br/>$alt<br/></center>\r\n";
为:
$revalue = "<center><a href='javascript:goNextPic();'><img src='$src' $iw/></a><br/>$alt<br/></center> ";原文链接:https://www.f2er.com/dedecms/534184.html