个人解决方式用 数组存储当前栏目排序的id 遍历数组 返回当前id的前后信息id
在e/class/function.php 添加如下函数 =================== //通过id判断上下一条 function nextprev($classid,$id) {//$public_r[newsurl] global $empire,$dbtbpre,$emod_r,$public_r,$class_r,$class_zr,$fun_r,$class_tr,$level_r,$etable_r; $a=array();$r=array(); $ii=0; if(empty($class_r[$classid][reorder])){$addorder="newstime desc";}else{$addorder=$class_r[$classid][reorder];} $sqltext="select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid' and checked=1 order by ".ReturnSetTopSql('list').$addorder." "; //echo $sqltext;exit; $sql=$empire->query($sqltext); //查询新闻表最新10条记录 while($rs=$empire->fetch($sql)) //循环获取查询记录 { $a[]=$rs["id"]; if($rs[id]==$id){$dqid=$ii;} $ii++; } $r[0]=$a[$dqid-1]; $r[1]=$a[$dqid+1]; //print_r($a); return $r;
} =================== //$r[0] 为下一篇id ,$r[1]为上一篇id;
改 =================== //下一篇 if(strstr($newstemptext,'[!--info.next--]')) { $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id>$add[id] and classid='$add[classid]' and checked=1 order by id limit 1"); if(empty($next_r[id])) { $infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>"; } else { //链接 $nexttitleurl=sys_ReturnBqTitleLink($next_r); $infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>"; } $newstempstr=str_replace('[!--info.next--]',$infonext,$newstempstr); } //上一篇 if(strstr($newstemptext,'[!--info.pre--]')) { $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$add[id] and classid='$add[classid]' and checked=1 order by id desc limit 1"); =================== 为: =================== $np=nextprev($add[classid],$add[id]); //下一篇 if(strstr($newstemptext,'[!--info.next--]')) { $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id='$np[0]' and classid='$add[classid]' and checked=1 order by id limit 1"); if(empty($next_r[id])) { $infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>"; } else { //链接 $nexttitleurl=sys_ReturnBqTitleLink($next_r); $infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>"; } $newstempstr=str_replace('[!--info.next--]',$infonext,$newstempstr); } //上一篇 if(strstr($newstemptext,'[!--info.pre--]')) { $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id='$np[1]' and classid='$add[classid]' and checked=1 order by id desc limit 1"); =================== 以上修改能完成效果,但是 资源耗用太大,求精改
|
[该贴被修改 1 次,最后修改时间 2012-08-29 14:56:18 ]
BLOG 百度
|