当前位置: 首页 > cms教程

帝国CMS怎么用TAG调用相关文章

时间:2026-01-25 17:05:33

用tag调用相关文章的方法在帝国官方论坛上有人发过方法,但所使用的函数效率太低而且无法制定参数,不好用。现在使用的也是利用tag调用相关文章,非常好用。
一、自定义函数
自定义函数user_OtherLink ,将此函数放入 eclassuserfun.php 文件中。
//根据tag获取相关信息

function user_OtherLink($num,$classid=0,$mid=0){ global $dbtbpre,$empire,$navinfor,$class_r; if(empty($navinfor['infotags'])){ return '暂无相关信息'; } if($mid&&$classid&&$class_r[$classid]['modid']!=$mid){ return '暂无相关信息'; } $tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1"); $temp_r=explode("[!--empirenews.listtemp--]",$tr['otherlinktemp']); $str=''; $tagsql=$empire->query("select * from {$dbtbpre}enewstagsdata where id='$navinfor[id]' and classid='$navinfor[classid]'"); $i=0; $isprint=array(); while($tagr=$empire->fetch($tagsql)){ if($i>=$num){ break; } $gsql=$empire->query("select * from {$dbtbpre}enewstagsdata where tagid='$tagr[tagid]'"); while($gr=$empire->fetch($gsql)){ $myprint='id'.$gr['id'].'class'.$gr['classid']; if(array_search($myprint,$isprint)!==false){ continue; } $isprint[]=$myprint; if($classid&&$classid!=$gr['classid']){ continue; } if($mid&&$mid!=$gr['mid']){ continue; } if($gr['id']==$navinfor['id']&&$gr['classid']==$navinfor['classid']){ continue; } $tbname=$class_r[$gr['classid']]['tbname']; if(!$tbname||InfoIsInTable($tbname)){ continue; } $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$gr[id]' limit 1"); if(!$r['id']){ continue; } $str.=RepOtherTemp($temp_r[1],$r,$tr); $i+=1; if($i>=$num){ break; } } } $keyboardtext=$temp_r[0].$str.$temp_r[2]; if($str){ return $keyboardtext; }else{ return '暂无相关信息'; }}

二、 使用方法:
函数说明:user_OtherLink(调用条数,指定栏目id,指定模型id) ;
相关文章模板采用的是公共模板里的相关信息模板。
调用示例:
<?=user_OtherLink(10,0,1)?>


上一篇:帝国CMS程序在IIS环境下设置伪静态的教程
下一篇:帝国cms全站搜索模板支持灵动标签调用的方法!
相关文章
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素