建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > 建站必知 > phpcms手机版中判断上一篇下一篇没有就输出无

phpcms手机版中判断上一篇下一篇没有就输出无

时间:2017-07-25 16:01:44  来源:免费模板网 作者:风雪 阅读次数 tagsphpcms

默认在phpcms手机版文章详情里面是没有上一盘,下一篇这个功能的,想添加这个怎么实现呢。我们可以把pc端的代码copy过去。

注意代码添加的位置,大约在99行之后添加下面代码,文件路径在 phpcms\modules\wap\index.php

25.jpg

$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是否为空来判断输出

26.jpg

本文地址:https://www.freemoban.com/jzbz/2017/0725/2854.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!