内容页调用tag,按tagname调用
<div class="tagsline">Tags:<? $a="$navinfor[infotags]"; $str=str_replace(',', ',', $a); $tag=''; $t= explode(",", $str); for($i=0;$i<count($t);$i++) { if($t[$i]) { $tagslink="[!--news.url--]e/tags/?tagname=".urlencode($t[$i])."&tempid=1"; $tag.="<a href='$tagslink' target='_blank'>".$t[$i]."</a> "; } } echo $tag; ?> </div>
或,按tagname调用
<?php $fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_news_data_{$navinfor[stb]} where id='$navinfor[id]'"); $infotags=$fr['infotags'];//这个就是infotags字段内容 $tag=''; $t=explode(',',$infotags);//去逗号 $d=count($t); for($i=0;$i<count($t);$i++) { if($t[$i]) { $tagslink="[!--news.url--]e/tags/?tagname=".urlencode($t[$i])."&tempid=1"; $tag.="<a href='$tagslink' target='_blank'>".$t[$i]."</a> "; } } echo $tag; ?>
或,按id调用
<? $tbname=$class_r[$navinfor['classid']]['tbname']; $ftbname=$dbtbpre."ecms_".$tbname."_data_".$navinfor['stb']; $hlt = $empire->fetch1("select infotags from {$ftbname} where id='$navinfor[id]'"); $a=$hlt[infotags]; $str=str_replace(',', ',', $a); $tag=''; $t= explode(",", $str); for($i=0;$i<count($t);$i++) { if($t[$i]) { $datar=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$t[$i]' limit 1"); $tagslink="[!--news.url--]e/tags/?tagid=".$datar[tagid].""; $tag.="<a href='$tagslink' target='_blank'>".$t[$i]."</a> "; } } echo $tag; ?>
注释:
限制数量,把$i<count($t)修改为$i<count($t)&&$i<限制数量
mid=1数据模型id tempid=1模型的模板id orderby排列方式 classid=34栏目id &line=5调用条数
如:上面的 &tempid=1
如果想用静态以ID的HTML 可以参考下面这个
<p >本文标签:<? $tbname=$class_r[$navinfor['classid']]['tbname']; $ftbname=$dbtbpre."ecms_".$tbname."_data_".$navinfor['stb']; $hlt = $empire->fetch1("select infotags from {$ftbname} where id='$navinfor[id]'"); $a=$hlt[infotags]; $str=str_replace(',', ',', $a); $tag=''; $t= explode(",", $str); for($i=1;$i<count($t);$i++) { if($t[$i]) { $datar=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$t[$i]' limit 1"); $tagslink="[!--news.url--]tag/".$datar[tagid].".html"; $tag.="<a href='$tagslink' style='color:red;font-size:14px' target='_blank'>".$t[$i]."</a> "; } } echo $tag; ?></p>
赞
帝国cms标签
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。