帝国CMS模板内容页怎么用TAG调用相关文章
发布时间:2021-03-31作者:帝国建站网
帝国cms模板内容页现用TAG调用相关文章的方法,一起来看看怎么操作吧:
用tag调用相关文章的方法在帝国官方论坛上有人发过方法,但所使用的函数效率太低而且无法制定参数,不好用。现在使用的也是利用tag调用相关文章,非常好用。
一、自定义函数
自定义函数user_OtherLink ,将此函数放入 e\class\userfun.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)?>
相关帝国教程
- 11-03栏目自定义字段ReturnClassAddField标签截取字数方法
- 02-09帝国CMS7.2升级到7.5方法
- 07-10帝国cms模板里显示发布信息人的ip地址
- 11-20帝国cms修改实现TAG标签以TAGID的方式伪静态
- 10-10详解帝国CMS自定义列表多表联合查询的方法
- 08-07帝国cms内容页某个字段没有填写就不显示的解决方法
- 05-04帝国cms数据表phome_ecms_news_data_1
- 05-19帝国cms万能调用指定栏目名称与url链接及别名标签是什么?
- 06-11帝国CMS使用灵动标签调用上一篇下一篇的方法
- 05-28帝国CMS获取当前无限极栏目信息
- 08-10帝国cms内容页模板点击量数值过万时,换成万为单位
- 10-03帝国CMS二次开发格式实例
- 04-16帝国调用评论我的信息列表
- 05-01帝国CMS模板内容页没有相关信息
- 05-24帝国CMS二次开发内容点击无限加载思路分享
- 02-16帝国CMS内容页调用该会员所发的文章数
- 06-10帝国cms tags 页列表页内容页调用函数版代码是什么?
- 10-12帝国CMS7.5内核版本tags伪静态设置方法静态规则方法是什么?
- 08-08帝国cms自动获取当前栏目链接的标签
- 09-26帝国CMS调用我的评论列表方法