颠覆与创新

超态信息插件 Sinfo

不想变成栏目的信息不是好信息

更新时间:2016-05-02
首页 > 帝国cms使用技巧 > 帝国CMS实现用tag调用相关文章

帝国CMS实现用tag调用相关文章

来源:东坡网   作者:有故事的人   发布日期:2015-03-04 12:20:24   阅读次数:6692

用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)?>
版权说明:本文由 东坡网 原创,版权归东坡网所有,欢迎转载,但请保留来源于东坡网。署名的转载是对我们最大的支持,感谢!
相关文档
相关插件
联系我们

技术支持:点击这里给我发消息

其它咨询:点击这里给我发消息

微信号:imDP1037,注明东坡网

ECMS互助QQ群:308293433

©2013-2019 DP1037.COM东坡网,致力于帝国cms插件和二次开发,为帝国cms加油! 备案号:粤ICP备14036885号-2

本页采用东坡网【动态页缓存插件】,当前页面缓存时间 2024-04-19 10:54:13
本次重新生成缓存,总耗时 0.0061159133911133 秒