PHPCMS 实现上一篇下一篇的几种方法

本文介绍三种在PHP页面中实现上下篇内容导航的方法,包括直接使用SQL查询、通过JavaScript调用PHP文件以及利用标签和样式进行布局。
1第一种

 <p>上一篇:

{get sql = "select contentid,catid,url,titlee from phpcms_content where contentid <'$contentid' and catid='$catid' order by contentid desc" rows="1" return="v"}{php $front=1;}<a href="{$v[url]}">{$v[title]}</a> {/get}{if $front!=1}无{/if}</p>

  <p>下一篇:

{get sql = "select contentid,catid,url,titlee from phpcms_content where contentid >'$contentid' and catid='$catid' order by contentid desc" rows="1" return="v"}{php $front=2;}<a href="{$v[url]}">{$v[title]}</a> {/get}{if $front!=2}无{/if}</p>

 

2第二种

 这种方法是js调用方法,需要下载附件中的一个php文件,放在网站根目录

<p>上一篇:

<script type="text/javascript" src="{$PHPCMS[siteurl]}page.php?contentid={$contentid}&catid={$catid}" langage="javascript"></script></p>

<p>下一篇:

<script type="text/javascript" src="{$PHPCMS[siteurl]}page.php?contentid={$contentid}&catid={$catid}" langage="javascript"></script></p>

 

 

3第三种方法:

{get sql="select * from phpcms_content where contentid>$contentid and catid=$catid order by updatetime desc" rows="1"}

<div style="float:left">上一篇:

<a href="{$r[url]}" title="{$r[title]}" target="_blank">{str_cut($r[title],70)}</a></div>

{/get}

{get sql="select * from phpcms_content where contentid<$contentid and catid=$catid order by updatetime desc" rows="1"}

<div style="float:right">下一篇:

<a href="{$r[url]}" title="{$r[title]}" target="_blank">{str_cut($r[title],70)}</a></div>

{/get}

 

 

 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/qhorse/p/4578423.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值