加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

帝国CMS实现通过用tag标签挪用相干文章

发布时间:2021-01-12 06:42:50 所属栏目:教程 来源:网络整理
导读:用tag挪用相干文章的要领在帝国官方论坛上有人发过要领,但所行使的函数服从太低并且无法拟定参数,欠好用。东坡网此刻行使的也是操作tag挪用相干文章,很是好用。 一、自界说函数 自界说函数user_OtherLink ,将此函数放入 eclassuserfun.php 文件中。 //根

用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,1)?>

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读