帝國cms按tag調用相關內容,數量不夠調用最新文章的代碼。
1、根據tag調用相關的文章10條,不夠調用最新文章
代碼如下
function user_newslist($classid,$id,$num=10){
global $empire,$dbtbpre,$class_r;
$tbname=$class_r[$classid]['tbname'];
$tr=$empire->fetch1("select tagid from {$dbtbpre}enewstagsdata where id=".$id." and classid=".$classid."");
if($tr){
$sql="select * from {$dbtbpre}enewstagsdata as a LEFT JOIN {$dbtbpre}ecms_{$tbname} as b ON a.id=b.id where a.tagid={$tr[tagid]} and a.id<>{$id} limit ".$num;
$tsql=$empire->query($sql);
while($tt=$empire->fetch($tsql)){
$str.='<li> <a href="'.$tt[titleurl].'.html">'.$tt[title].'</a></li>';
$num--;
}
$num=$num-$total;
$sql2="select * from {$dbtbpre}ecms_{$tbname} limit ".$num;
$tsql2=$empire->query($sql2);
while($tt2=$empire->fetch($tsql2)){
$str.='<li> <a href="'.$tt2[titleurl].'.html">'.$tt2[title].'</a></li>';
}
}
return $str;
}