
帝国cms默许的[!--other.link--]标签调用相关链接时,如果没有相关链接的话,则会显现“暂无相关链接”。对于一些收集站或其他需要增加内链的网站来说,此时最好能调用本栏目的其它一些信息挖充出去。这里分享一个本人用的函数,实现这个功能。
function dp_GetKeyboard($num=100){
global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$class_r,$navinfor;
$keykeyid'];
$classclassid'];
$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=" class 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;
}
当信息有相关信息时,调用相关信息,如果没有,则调用同栏目、当前信息前后100个id之内的信息中宣布时候最靠近的,100可以设置成参数。将此函数放进 userfun.php 文件中,正在模板中调用圆法:
<?=dp_GetKeyboard(200)?>
列表模板正在这里设置:

转载请注明: 帝国模板 » 帝国CMS 无相关信息时调用其它信息圆法利于劣化以及挖充位置
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
