帝国cms内容页面调用相关文章信息
相关信息
默认的[!–other.link–]标签调用相关链接时,如果没有相关链接的话,则会显示“暂无相关链接”。
对于一些采集站或其他需要增加内链的网站来说,此时最好能调用本栏目的其它一些信息填充进来。这里分享一个函数,实现这个功能。
<font face="宋体">function dp_GetKeyboard($num=100){
global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$class_r,$navinfor;
$keyid=$navinfor['keyid'];
$classid=$navinfor['classid'];
$id=$navinfor['id'];
$link_num=$class_r[$classid]['link_num'];
if(!$link_num){
return $fun_r['NotLinkNews'];
}
$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");
$temp_r=explode("[!–empirenews.listtemp–]",$tr[otherlinktemp]);
if($keyid){
$add="id in (".$keyid.")";
}else{
$e=$id+$num;
$s=$id-$num;
$add=" classid=".$classid." and id>".$s." and id<".$e;
}
$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add." order by newstime desc limit $link_num");
while($link_r=$empire->fetch($key_sql)){
if($link_r['id']==$id){
continue;
}
$keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);
}
if(empty($keyboardtext)){
return $fun_r['NotLinkNews'];
}
$keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];
return $keyboardtext;
}</font>
当信息有相关信息时,调用相关信息,如果没有,则调用同栏目、当前信息前后100个id之内的信息中发布时间最靠近的,100可以设置成参数。
将以上函数放进userfun.php 文件中,
在模板中调用方法如下:
<?=dp_GetKeyboard(200)?>
1、如非特殊说明,本站对本文提供的代码或者素材不拥有任何权利,其版权归原著者拥有。
2、以上提供的代码或者素材均为作者提供和网友推荐收集整理而来,仅供学习和研究使用。
3、如有侵犯你版权的,请来信(邮箱:admin@mail.52muban.com)指出,核实后,本站将立即改正。
4、如有链接无法下载、失效或广告,请点击下面的报错或者联系我们处理!
5、以上资源售价只是赞助,不代表代码或者素材本身价格。收取费用仅维持本站的日常运营所需!
6、本站所有资源、教程、源码,不得用于非法站点及用途,后果自负!本站不为非法站点提供任何服务。
我爱模板网 帝国cms教程 帝国cms内容页模板相关信息 https://www.52muban.com/129450.html


常见问题