帝国CMS 暂无相关链接调用当前栏目其它信息方法是什么?


帝国CMS默认的相关链接标签[!--other.link--]在调用相关链接时,如果没有其它相关链接的话,会显示“暂无相关链接”。对于需要增加内链的网站来说,此时最好能调用本栏目的其它一些信息填充进来。这里介绍一个通过增加函数来实现这个功能的方法,样式还是系统原来自带的样式。
找到/e/class/userfun.php 将此函数放进此文件中,代码:

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;} 当信息有相关信息时,调用相关信息,如果没有调用同栏目、当前信息前后100个id之内的信息中发布时间最靠近的文章。

函数在模板中调用方法:<?=dp_GetKeyboard(200)?>,放在相关内容的地方调用

上一篇:帝国CMS列表页按digg数评论数或指定类型排序如何修改?

下一篇:帝国CMS邮件无法发送SSL465端口无法发送的解决办法


函数 调用 相关链接
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器