文章采集调用(免费资源网,用调用相关文章的方法在帝国官方论坛上)
优采云 发布时间: 2021-12-07 18:20文章采集调用(免费资源网,用调用相关文章的方法在帝国官方论坛上)
免费资源网,
使用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);
相关文章模板使用公共模板中的相关信息模板。
调用示例:
免费资源网,
伟大的
帝国cms
免责声明:本站所有文章,除非另有说明或标注,均在本站原创上发布。任何个人或组织未经本站同意,不得复制、盗用、采集、将本站内容发布到网站、书籍等任何媒体平台。本站侵犯原作者合法权益的,您可以联系我们进行处理。