1. 程式人生 > >PHPCMS 手機門戶文章添加下一篇和上一篇

PHPCMS 手機門戶文章添加下一篇和上一篇

php previous span cat scrip clas ive ast nbsp

一、在phpcms\modules\wap\index.php裏面,搜索下面這句代碼

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"); 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‘).‘\‘);‘); }

三、模板中的調用代碼如下

<!-- <a class="active" href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id={$previous_page[id]}" style="width: 26%;">
    上一篇
</a>
<a class="active" href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id={$next_page[id]}" style="width: 26%;">
    下一篇
</a> --> <a class="active" href="/show-{$catid}-{$typeid}-{$previous_page[id]}-1.html" style="width: 26%;"> {if $previous_page[id] == 0}沒有了{else}上一篇{/if} </a> <a class="active" href="/show-{$catid}-{$typeid}-{$next_page[id]}-1.html" style="width: 26%;"> {if $next_page[id] == 0}沒有了{else}下一篇{/if} </a>

PHPCMS 手機門戶文章添加下一篇和上一篇