帝国CMS列表内容模板调用TAG的两种方法代码

2018-02-0105:20:09网站建设与开发Comments3,036 views字数 1296阅读模式

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

/* 列表页显示tag 开始*/
$tagstr='';
$tsql=$empire->query("select tagid from {$dbtbpre}enewstagsdata where id='$r[id]' and classid='$r[classid]' ");
while($tr=$empire->fetch($tsql)){
$tt=$empire->fetch1("select * from {$dbtbpre}enewstags where tagid=".$tr['tagid']." limit 1");
if(!$tt['tagid']){
continue;
}else{文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

//tagid式的动态链接,采用以下1行代码
$tagslink=$public_r['newsurl'].'e/tags/?tagid='.$tt['tagid'];文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

}
$tagstr.='<a href="'.$tagslink.'" title="'.$tagname.'" target="_blank">'.$tt['tagname'].'</a>';
}
/*结束*/文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

$listtemp='  '.$tagstr.' ';文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

注释: $tagslink=$public_r['newsurl'].'e/tags/?tagid='.$tt['tagid']; 中的tagid='.$tt['tagid'];可改为 tagname='.$tt['tagname'];文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

tagid后加&line=5调用条数文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

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

$classid=$r[classid]; //获取栏目id
$tbname=$class_r[$classid][tbname];//获取数据表
$fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_{$r[stb]} where id='$r[id]'");//查询副表下的infotags字段
$tag1=''.$fr[infotags].'';
$r_tag=explode(",",$tag1);
for($i=0;$i<count($r_tag)&&$i<3;$i++)
{
if($r_tag[$i])
{
$tagslink=$public_r[newsurl]."e/tags/?tagname=".$r_tag[$i];//链接
$tags.="<a href='$tagslink' target='_blank'>".$r_tag[$i]."</a> ";文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

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

if(empty($fr[infotags]))
{
$tags="无";
}文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

$listtemp='      标签:'.$tags.'     ';文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

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

$i<count($r_tag)&&$i<3;中的3为调用3条tag文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

或 tagid后加&line=5调用条数文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/202.html

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

Comment

匿名网友 填写信息

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

确定