帝国CMS怎么用TAG调用相关文章
用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)?>
声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至201542412@QQ.com举报,一经查实,本站将立刻删除。
相关推荐
-
帝国cms灵动标签调用相关文章,SQL语句指定关键词调用文章
帝国cms灵动标签调用相关文章,SQL语句指定关键词调用,帝国cms根据指定关键词调取相关文章的方式有下面几种
-
帝国CMS内容页相关文章调用
标题包含关键字①、比较粗糙的匹配,可能不太精确:titllik'%$navinfor[kyboard]%'②、精确的匹配,比较消耗资源:titlrgxp'(^|,)$navinfor[kyboard]($|,)'...
-
帝国CMS没有相关文章,则调用最新文章的方法代码
帝国CMS文章内容页可以通过!--othr.link--调用相关链接,这个标签在后台编辑内容页模板时,通过模板变量说明可以找到。使用该标签可以在后台系统设置中设置相关链接依据(标题
-
帝国CMS内容页根据关键词来调用相关文章
帝国cms内容页根据关键词来调用相关内容,如果没有相关内容则随机获得文章代码。?phpif($navinfor){$cky=xplod(,,$navinfor);$count=count
-
帝国CMS灵动标签调用相关文章的方法
标题包含关键字①、比较粗糙的匹配,可能不太精确:titllik%$navinfor%②、精确的匹配,比较消耗资源:titlrgxp(^|,)$navinfor($|,)&