导航
当前位置:网站首页 > 站长新闻 > CMS教程 > 织梦手机网站内容页上一篇下一篇调用实现翻页功能

织梦手机网站内容页上一篇下一篇调用实现翻页功能

作者:达特 日期:2023-05-22 分类:CMS教程

修改织梦include/arc.archives.class.php文件。

织梦手机网站内容页上一篇下一篇调用实现翻页功能

1、搜索
function GetPreNext($gtype='')
2、将这个函数的所有内容替换为

01 function GetPreNext($gtype='')
02     {
03         $rs = '';
04         if(count($this->PreNext)<2)
05         {
06             $aid = $this->ArcID;
07 $preR =  $this->dsql->GetOne("Select id From `dede_arctiny` where id<$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc");
08 $nextR = $this->dsql->GetOne("Select id From `dede_arctiny` where id>$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc");
09 $next = (is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ');
10 $pre = (is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ');
11 $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,
arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
12  t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
13  from `dede_archives` arc left join dede_arctype t on arc.typeid=t.id  ";
14             $nextRow = $this->dsql->GetOne($query.$next);
15             $preRow = $this->dsql->GetOne($query.$pre);
16             if(is_array($preRow))
17             {
18 $mlink = GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],
$preRow[
'title'],$preRow['ismake'],$preRow['arcrank'],
19 $preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow
[
'moresite'],$preRow['siteurl'],$preRow['sitepath']);
20 $mobile_mlink = "/m/view.php?aid=".$preRow['id'];
21 $this->PreNext['pre'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
22 $this->PreNext['mobile_pre'] = "上一篇:<a href='$mobile_mlink'>{$preRow['title']}</a> ";
23 $this->PreNext['preimg'] = "<a href='$mlink'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> ";
24             }
25             else
26             {
27                 $this->PreNext['pre'] = "上一篇:没有了 ";
28                 $this->PreNext['mobile_pre'] = "上一篇:没有了 ";
29 $this->PreNext['preimg'] ="<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起没有上一图集了!\"/>";
30             }
31             if(is_array($nextRow))
32          {
33 $mlink = GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title']
,$nextRow[
'ismake'],$nextRow['arcrank'],
34 $nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],
$nextRow[
'filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);
35 $mobile_mlink = "/m/view.php?aid=".$nextRow['id'];
36 $this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
37 $this->PreNext['mobile_next'] = "下一篇:<a href='$mobile_mlink'>{$nextRow['title']}</a> ";
38 $this->PreNext['nextimg'] = "<a href='$mlink'><img src=\"{$nextRow['litpic']}\" alt=\"
{$nextRow['title']}\"/></a> "
;
39             }
40             else
41             {
42     $this->PreNext['next'] = "下一篇:没有了 ";
43      $this->PreNext['mobile_next'] = "下一篇:没有了 ";
44 $this->PreNext['nextimg'] ="<a href='javascript:void(0)' alt=\"\"><img src=\"
/templets/default/images/nophoto.jpg\" alt=
\"对不起,没有下一图集了!\"/></a>"
;
45             }
46         }
47         if($gtype=='pre')
48         {
49             $rs =  $this->PreNext['pre'];
50         }
51         else if($gtype=='preimg'){
52             $rs =  $this->PreNext['preimg'];
53         }       
54         else if($gtype=='mobile_pre'){
55             $rs =  $this->PreNext['mobile_pre'];
56         }
57         else if($gtype=='next')
58         {
59             $rs =  $this->PreNext['next'];
60         }       
61         else if($gtype=='mobile_next')
62         {
63             $rs =  $this->PreNext['mobile_next'];
64         }
65         else if($gtype=='nextimg'){
66             $rs =  $this->PreNext['nextimg'];
67         }
68         else
69         {
70             $rs =  $this->PreNext['pre']." &nbsp; ".$this->PreNext['next'];
71         }
72         return $rs;
73     }
3、在织梦手机网站内容详情页模板内,将调用上一篇、下一篇标签插入。
    <ul class="am-pagination blog-pagination">
     <li>{dede:prenext get='mobile_pre'/}</li>
     <div style="clear:both;"></div>
     <li>{dede:prenext get='mobile_next'/}</li>
   </ul>

猜你还喜欢