自由之人 發表於 2023-8-13 00:00:00

DEDECMS点击图片进入下一页功能实现教程

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        关于使用Phpcms程序的站长,请参照以前发表过的PhpCMS点击<u>图片</u>进入下一页教程,那么DedeCMS能否实现呢,回答是可以的,今天将方法告诉大家。 <br>
        直接入正题,特点是:不修改源码,只在模板上做处理。 <br>
        修改 include/arc.archives.class.php <br>
        1.查找“//解析模板,对内容里的变动进行赋值”在这段话上面添加以下代码 : <br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode6" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        function ClickPicNext($ismake=1,$aid,&amp;$body) <br>
        { <br>
        global $cfg_rewrite; <br>
        if($this-&gt;NowPage!=$this-&gt;TotalPage) <br>
        { <br>
        $lPage=$this-&gt;NowPage+1; <br>
        if($ismake=0) <br>
        { <br>
        $body=preg_replace("/&lt;(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)&gt;)/isU","点击图片,进入下一页&lt;br/&gt;&lt;a href='".$this-&gt;NameFirst."_".$lPage.".".$this-&gt;ShortName."'&gt;"."\${0}"."&lt;/a&gt;",$body); <br>
        } <br>
        else <br>
        { <br>
        $PageList="&lt;a href='view.php?aid=$aid&amp;pageno=$lPage'&gt;"."\${0}"."&lt;/a&gt;"; <br>
        if($cfg_rewrite == 'Y') <br>
        { <br>
        $PageList = str_replace(".php?aid=","-",$PageList); <br>
        $PageList = preg_replace("/&amp;pageno=(\d+)/i",'-\\1.html',$PageList); <br>
        } <br>
        $body=preg_replace("/&lt;(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)&gt;)/isU",$PageList,$body); <br>
        } <br>
        } <br>
        else <br>
        { <br>
        $body=preg_replace("/&lt;(img|IMG)(.*)(src|SRC)=[\"|'| ]{0,}((.*)&gt;)/isU",$this-&gt;GetPreNext('imgnext'),$body); <br>
        } <br>
        return $body; <br>
        } </div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2,查找$this-&gt;Fields[$this-&gt;SplitPageField] = $this-&gt;SplitFields[$pageNo - 1]; 在其下面添加 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>if($ClickPicNext){ </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$this-&gt;Fields[$this-&gt;SplitPageField]=$this-&gt;Fields[$this-&gt;SplitPageField]; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>}else{ </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$this-&gt;Fields[$this-&gt;SplitPageField]=$this-&gt;ClickPicNext($ismake,$this-&gt;Fields['id'],$this-&gt;Fields[$this-&gt;SplitPageField]); </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>} </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>3,查找$this-&gt;PreNext['next'] = "下一篇:&lt;a href='$mlink'&gt;{$nextRow['title']}&lt;/a&gt; ";在其下面添加 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$this-&gt;PreNext['imgnext'] ="&lt;a href='$mlink'&gt;"."\${0}"."&lt;/a&gt;"; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>4,查找$this-&gt;PreNext['next'] = "下一篇:没有了 ";在其下面添加 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$this-&gt;PreNext['imgnext'] ="\${0}"; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>5.查找 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>else if($gtype=='next') </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>{ </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>$rs = $this-&gt;PreNext['next']; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>} </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在其下面添加 </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode7" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        else if($gtype=='imgnext') <br>
        { <br>
        $rs = $this-&gt;PreNext['imgnext']; <br>
        } </div>
<div>
         </div>
頁: [1]
查看完整版本: DEDECMS点击图片进入下一页功能实现教程