帝国CMS内容页调用TAG五种方法!PHP和灵动还有样式改造!

2019-03-2616:25:36网站建设与开发Comments2,192 views字数 4433阅读模式

方法1、
调用10条当前tag
[showtags]'selfinfo',10,0,'',0,'',' ',0,'','tagname'[/showtags]文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

方法2、
内容页调用tag,按tagname调用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<div class="tagsline">Tags:<? $a="$navinfor[infotags]";
$str=str_replace(',', ',', $a);
$tag='';
$t= explode(",", $str);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

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>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

或,按tagname调用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?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;
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

或,按id调用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?
$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);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

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;
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

注释:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

限制数量,把$i<count($t)修改为$i<count($t)&&$i<限制数量文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

mid=1数据模型id  tempid=1模型的模板id   orderby排列方式  classid=34栏目id  &line=5调用条数文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

如:上面的 &tempid=1文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

---------------------------------------------------------------------------------------------------------------
方法3、tags标签实现多颜色样式
<?php
$ecms_bq_sql=sys_ReturnEcmsLoopBq("select * from [!db.pre!]enewstagsdata where classid='$navinfor[classid]' and id='$navinfor[id]' order by tagid",10,24,0);
$bqno=0;
while($bqr=$empire->fetch($ecms_bq_sql))
{
$bqsr=sys_ReturnEcmsLoopStext($bqr);
$bqno++;
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?php
$ecms_bq_sql2=sys_ReturnEcmsLoopBq("select * from [!db.pre!]enewstags where tagid='$bqr[tagid]' order by tagid",1,24,0);
$bqno2=0;
while($bqr2=$empire->fetch($ecms_bq_sql2))
{
$bqsr2=sys_ReturnEcmsLoopStext($bqr2);
$bqno2++;
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<a class="tag-<?=$bqno?>" href="<?=$public_r[newsurl]?>e/tags/?tagname=<?=$bqr2['tagname']?>&tempid=1"><?=$bqr2[tagname]?></a>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?php
}
}
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

接着在css中定义标签的样式,这个可以自己定义。
.tag-1{background:#ff7094;}
.tag-2{background:#94b770;}
.tag-3{background:#db94ff;}
.tag-4{background:#399;}
.tag-5{background:#f60;}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

注释:mid=1数据模型id  tempid=1模型的模板id   orderby排列方式  classid=34栏目id文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

如:上面的 &tempid=1文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

---------------------------------------------------------------------------------------------------------------
方法4、文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

[e:loop={"select a.*,b.* from [!db.pre!]enewstags a LEFT JOIN [!db.pre!]enewstagsdata b ON a.tagid=b.tagid where b.classid='$navinfor[classid]' and b.id='$navinfor[id]' group by b.tagid order by a.num desc limit 100",0,24,0}]
<a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a>
[/e:loop]文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

---------------------------------------------------------------------------------------------------------------
方法5、
<?php
$tsql=$empire->query("select * from {$dbtbpre}enewstagsdata where id='$navinfor[id]'order by id asc limit 7");
while($tr=$empire->fetch($tsql)){
$tag=$empire->fetch1("select * from {$dbtbpre}enewstags where tagid='$tr[tagid]' limit 1");
?>
<span><a class="tag" href="<?=$public_r[newsurl]?>e/tags/?tagname=<?=$tag['tagname']?>"><?=$tag[tagname]?></a></span>&nbsp;
<?}?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

方法6.(网友提供,感谢)
<?php
$tbname="news"; //“news”为新闻数据表名称
$ftbname=$dbtbpre."ecms_".$tbname."_data_".$navinfor['stb'];
$hlt = $empire->fetch1("select infotags from {$ftbname} where id='$navinfor[id]'");
$keyr=explode(',',$hlt[infotags]);
for($i=0;$i<count($keyr);$i++)
{
echo '<a href="'.$public_r[newsurl].'e/tags/?tagname='.$keyr[$i].'" target=_blank>'.$keyr[$i].'</a>&nbsp;&nbsp;';
}
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?php
$fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_news_data_{$navinfor[stb]} where id='$navinfor[id]'");
$keyr=explode(',',$fr[infotags]);
for($i=0;$i<count($keyr);$i++)
{
echo '<a href="'.$public_r[newsurl].'e/tags/?tagname='.$keyr[$i].'" target=_blank>'.$keyr[$i].'</a>&nbsp;&nbsp;';
}
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

<?php
$fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_news_data_{$navinfor[stb]} where id='$navinfor[id]'");
$infotags=$fr['infotags'];
$r_tag=explode(",",$infotags);
for($i=0;$i<count($r_tag);$i++){
if($r_tag[$i]){
$tagslink=$public_r[newsurl]."e/tags/?tagname=".urlencode($r_tag[$i]);
$tags.="<a class='tag-link19' href='$tagslink' target='_blank' rel='tag'>".$r_tag[$i]."</a>";
}
}
?>
tag:<?=$tags?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

注释:限制数量,把$i<count($keyr)修改为$i<count($keyr)&&$i<限制数量文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10396.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/10396.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定