PHPCMS 实现上一篇、下一篇

方法一:直接调用phpcms系统的函数
<div class="info">
    <span>上一篇:<a href="{$previous_page[url]}">{$previous_page[title]}</a></span>
    <span>下一篇:<a href="{$next_page[url]}">{$next_page[title]}</a></span>
</div>

方法二:下面的方法复杂了些,但该代码提供一种phpcms的调用数据的一种思路, 大家可以参考,这也是phpcms区别与其他系统的优势 

上一篇:
{pc:get sql="SELECT * FROM v9_news WHERE id < $id ORDER BY id DESC" num="1" return="p"}
  {loop $p $pv}
    {php $pid = "id = $pv[id]"}
    {pc:content action="lists" catid="$catid" where="$pid" order="id DESC" num="1"}
    <ul>
      {loop $data $key $val}
        <li> <a href="{$val[‘url‘]}">{$val[‘title‘]}</a></li>
      {/loop}
    </ul>
    {/pc}
  {/loop}
{/pc}
 
 下一篇:
{pc:get sql="SELECT * FROM v9_news WHERE id > $id ORDER BY id ASC" num="1" return="ne"}
  {loop $ne $nev}
    {php $neid = "id = $nev[id]"}
    {pc:content action="lists" catid="$catid" where="$neid" order="id DESC" num="1"}
    <ul>
    {loop $data $key $val}
      <li> <a href="{$val[‘url‘]}">{$val[‘title‘]}</a></li>
    {/loop}
    </ul>
    {/pc}
  {/loop}
{/pc}
				
时间: 2024-08-28 20:41:15

PHPCMS 实现上一篇、下一篇的相关文章

HQL实现新闻上一篇下一篇

要实现新闻的上一篇下一篇功能,关键是HQL语句 上一篇:HQL="from News d where d.id<? order by id desc"; 下一篇:HQL="from News d where d.id>? order by id asc "; daoImpl实现的方法: public News nextPage(News news){ try{ String queryString="from News d where d.id

HQL语句实现新闻上一篇下一篇

要实现新闻的上一篇下一篇功能,关键是HQL语句 上一篇:HQL="from News d where d.id<? order by id desc"; 下一篇:HQL="from News d where d.id>? order by id asc "; daoImpl实现的方法: public News nextPage(News news){ try{ String queryString="from News d where d.id

织梦正则自定义输出电脑站移动站上一篇下一篇文章

不去修改程序文件,用标签和正则直接在内容页模板里直接输出上一篇下一篇的链接和标题和没有上一篇下一篇的提示文字 电脑站上一篇下一篇的链接 <li> <a href="{dede:prenext get=pre runphp=yes}$url = @me;preg_match('/href=['"]?([^'"]+)/', $url, $match);@me = $match[1];{/dede:prenext}">上一篇</a> &

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

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]}&q

PHPCMS 手机门户文章添加下一篇和上一篇

一.在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",'

ASP.NET 实现上一篇文章 下一篇文章

select top 1 * from job_hrnews where newsid>162  --下一篇 select top 1 * from job_hrnews where newsid<162 order by newsid desc --上一篇 这篇源于网络,网址已经忘记,敬请谅解!

上一篇 ,下一篇 功能实现

例如当前文章的ID是4 sql如下: 上一篇: select  top 1  id,title from  tb_ScGongGao  where id<4 and isdel=0 order by addTime desc,id desc 下一篇: select  top 1 id,title from  tb_ScGongGao  where id>4 and isdel=0 order by addTime asc,id asc 一个倒序,一个正序, 取结果的TOP1 就是想要上下篇文章

asp.net MVC实现文章的上一篇下一篇

由于这个东西的原理没有什么难的(只是实现的时候有少量的坑),故直接上代码以便查阅.另:本文给出的Action附送了点击量统计. public ActionResult SingleNews(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var news = storeDB.articles.Find(id); var prev = storeDB.article

非分页中的上一篇下一篇sql语句如何写

上一页:where id=(select max(id) from examination where id < #{id} and class=#{class}) 下一页:where id=(select min(id) from examination where id > #{id} and class=#{class}) <小于号,>大于号

ThinkPHP3.2中文章内容页的上一篇,下一篇功能,以及分类功能的实现

上一篇下一篇功能的实现 模型层:注意:数据表的ID应为自动递增的情况下 public function newsBeforeAfter($url,$id,$cate_id){ //上一篇 $where=array(); $where['checks']=array('eq',1);//该条内容是否审核 $where['id']=array('lt',$id);//上一篇ID应该小于当前接收到的ID $where['cate_id']=array('eq',$cate_id);//分类ID $fr