帝国CMS 内容页如何调用tag标签 动态url和伪静态 url

内容页调用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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郑叔敲代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值