欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」帝国CMS模板内容页怎么用TAG调用相关文章

作者 : 自学哈 本文共1890个字,预计阅读时间需要5分钟 2022-11-26 共105人阅读
也想出现在这里? 联系我们

帝国CMS模板内容页现用TAG调用相关文章的方法,一起来看看怎么操作吧:

  用tag调用相关文章的方法在帝国官方论坛上有人发过方法,但所使用的函数效率太低而且无法制定参数,不好用。现在使用的也是利用tag调用相关文章,非常好用。

  一、自定义函数

  自定义函数user_OtherLink,将此函数放入e\class\userfun.php文件中。

//根据tag获取相关信息
functionuser_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("selectotherlinktemp,otherlinktempsub,otherlinktempdatefrom".GetTemptb("enewspubtemp")."limit1");
$temp_r=explode("[!–empirenews.listtemp–]",$tr['otherlinktemp']);
$str='';
$tagsql=$empire->query("select*from{$dbtbpre}enewstagsdatawhereid='$navinfor[id]'andclassid='$navinfor[classid]'");
$i=0;
$isprint=array();
while($tagr=$empire->fetch($tagsql)){
if($i>=$num){
break;
}
$gsql=$empire->query("select*from{$dbtbpre}enewstagsdatawheretagid='$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."whereid='$gr[id]'limit1");
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)?>

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」帝国CMS模板内容页怎么用TAG调用相关文章
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号