默认在phpcms手机版文章详情里面是没有上一盘,下一篇这个功能的,想添加这个怎么实现呢。我们可以把pc端的代码copy过去。
注意代码添加的位置,大约在99行之后添加下面代码,文件路径在 phpcms\modules\wap\index.php
$tablename = $this->db->table_name = $this->db->db_tablepre.$MODEL[$modelid]['tablename']; $r = $this->db->get_one(array('id'=>$id)); if(!$r || $r['status'] != 99) showmessage(L('info_does_not_exists'),'blank'); //上一页 $previous_page = $this->db->get_one("`catid` = '$catid' AND `id`<'$id' AND `status`=99",'*','id DESC'); //下一页 $next_page = $this->db->get_one("`catid`= '$catid' AND `id`>'$id' AND `status`=99",'*','id ASC'); if(empty($previous_page)) { $previous_page = array('title'=>L('first_page'), 'thumb'=>IMG_PATH.'nopic_small.gif', 'url'=>'javascript:alert(\''.L('first_page').'\');'); } if(empty($next_page)) { $next_page = array('title'=>L('last_page'), 'thumb'=>IMG_PATH.'nopic_small.gif', 'url'=>'javascript:alert(\''.L('last_page').'\');'); }
然后在html里面调用 phpcms\templates\default\wap\show.html 在输出的地方加个判断
<div class="page next-page"><span>上一条: {if $previous_page[id] == ''}没有了{else} <a href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id={$previous_page[id]}"> {$previous_page[title]} {/if}</a></span></div> <div class="page next-page"><span>下一条: {if $next_page[id] == ''}没有了 {else} <a href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id={$next_page[id]}"> {$next_page[title]} {/if}</a></span></div>
根据id是否为空来判断输出