帝国CMS超级TAG管理插件-调用信息的TAG

1、调用信息TAG的函数,放进 e/class/userfun.php 文件 ?> 代码之前,方便在模板中调用.

/***
$classid   信息栏目id
$id        信息id
$exp       包裹每一个tag的前后标签,用|分割,默认是<li><a href="">TAG</a></li>
$limit     调用tag数量,默认10个
***/
function dp_InfoTag($classid,$id,$exp="<li>|</li>",$limit=10){
	global $dbtbpre,$empire,$public_r;
	$tagstr='';
	$i=0;
	$q=explode("|",$exp);
	$tsql=$empire->query("select tagid from {$dbtbpre}enewstagsdata where id=".$id." and classid=".$classid."");
	while($tr=$empire->fetch($tsql)){
		$tt=$empire->fetch1("select * from {$dbtbpre}enewstags where tagid=".$tr['tagid']." limit 1");
		if($tt['tagid']){
			if($i>$limit&&$limit){
				break;
			}
			$tagurl=dp_itagLink($tr['tagid']);
 			$tagstr.=$q[0].'<a href="'.$tagurl.'" title="'.$tt['tagname'].'" class="c1" target="_blank">'.$tt['tagname'].'</a>'.$q[1];
			$i+=1;
		}
	}
	return $tagstr;
}

2、在内容页模板中使用上述dp_InfoTag函数,调用当前信息的tag

<?=dp_InfoTag($navinfor['classid'],$navinfor['id'],'|<br>',8)?>

3、在列表页中,列表内容模板(list.var) 使用dp_InfoTag函数的例子:

$tagstr=dp_InfoTag($r['classid'],$r['id'],'| ',5);

$listtemp='
<li>
	<h3><a href="[!--titleurl--]">[!--title--]</a></h3>
	<p>[!--smalltext--]</p>
	TAG:'.$tagstr.'
</li>
';

注意需要勾选使用程序代码。帝国CMS列表模板list.var使用程序代码

4、灵动标签中使用dp_InfoTag函数的例子:

[e:loop={灵动标签调用语句}]
<?
$thistagstr=dp_InfoTag($bqr['classid'],$bqr['id'],'| ',10);
?>
<a href="" target="_blank"></a>
TAG: <?=$thistagstr?>
[/e:loop]