Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Dream weaving to realize the method of clicking the picture to turn the page of the atlas

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

织梦实现图集单击图片翻页的方法?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!

织梦怎么实现图集单击图片翻页?

织梦DEDECMS实现图集单击图片翻页的功能

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代码:

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); } } }

在这个js脚本中,我们定义一个方法goNextPic用来切换到下一个图片。

3、最后修改图片输出代码,完成goNextPic方法调用

修改include/inc_channel_unit.php

找到"//全部列出式或分页式图集"的部分。

修改类似(仔细看代码,需要修改好几个地方):

$revalue = "

$alt

$alt\r\n";

For:

$revalue = "

$alt

$alt "; Thank you for reading! After reading the above, do you know about the method of clicking pictures to turn pages in Dream Weaving Atlas? I hope the content of this article is helpful to everyone. If you want to know more about related articles, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report