此教程教大家如何实现织梦CMS图片集模型,点击图片进入下一张图片,最后一张图片进入下一篇图片。
用于测试的是DedeCmsV5.7版本,其他版本未测试,请慎用修改前请先备份。
首先打开include/arc.archives.class.php
1、搜索找到解析模板在注释的上一行加入下面代码:
//点击进入下一页function ClickPicNext($ismake=1,$aid,&$body){global $cfg_rewrite;if($this->NowPage!=$this->TotalPage){$lPage=$this->NowPage+1;if($ismake==1){$body=preg_replace("/<(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)>)/isU","<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."'>"."\${0}"."</a>",$body);}else{$PageList="<a href='view.php?aid=$aid&pageno=$lPage'>"."\${0}"."</a>";if($cfg_rewrite == 'Y'){$PageList = str_replace(".php?aid=","-",$PageList);$PageList = preg_replace("/&pageno=(\d+)/i",'-\\1.html',$PageList);}$body=preg_replace("/<(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)>)/isU",$PageList,$body);}}else{$body=preg_replace("/<(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)>)/isU",$this->GetPreNext('imgnext'),$body);}return $body;}
如图
2、找到
$this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
下面插入如下内容(大概在825行):
$this->PreNext['imgnext'] ="<a href='$mlink'>"."\${0}"."</a>";
3、找到
$this->PreNext['next'] = "下一篇:没有了 ";
下面插入如下内容(大概在830行):
$this->PreNext['imgnext'] ="<a href='$mlink'>"."\${0}"."</a>";
4、找到
$this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1];
下面插入如下内容(大概在715行):
if($ClickPicNext){$this->Fields[$this->SplitPageField]=$this->Fields[$this->SplitPageField];}else{$this->Fields[$this->SplitPageField]=$this->ClickPicNext($ismake,$this->Fields['id'],$this->Fields[$this->SplitPageField]);}
5、找到
else if($gtype=='nextimg'){$rs = $this->PreNext['nextimg'];}
下面插入如下内容(大概在849行):
else if($gtype=='imgnext'){$rs = $this->PreNext['imgnext'];}
修改前记得备份,修改后可以进入图片集测试点击最后一张图片进入下一篇图集。