帝国CMS模板调用指定栏目的tag或当前栏目tag的四种方法

调用指定栏目中所有数据包含的TAG或者当前栏目中所有数据包含的TAG,使用如下方法即可实现
方式1
  1. [e:loop={"select DISTINCT([!db.pre!]enewstags.tagname),[!db.pre!]enewstags.tagid,[!db.pre!]enewstags.num from [!db.pre!]enewstags inner join [!db.pre!]enewstagsdata on [!db.pre!]enewstags.tagid = [!db.pre!]enewstagsdata.tagid where [!db.pre!]enewstagsdata.classid = 3 order by [!db.pre!]enewstags.num DESC limit 30",0,24}]
  2. <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a>
  3. [/e:loop]
复制代码
方式2(和上面的相同,只是sql格式有稍微不同)
  1. [e:loop={"select a.tagname,a.num,b.tagid from [!db.pre!]enewstags a,[!db.pre!]enewstagsdata b where a.tagid=b.tagid and classid=3 group by tagid order by num desc  limit 40",40,24,0}]
  2. <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a>
  3. [/e:loop]
复制代码
方式3(和上面的相同,只是sql格式有稍微不同)
  1. [e:loop={"select a.*,b.* from [!db.pre!]enewstags a,[!db.pre!]enewstagsdata b where a.tagid=b.tagid and classid=3 group by b.tagid order by a.num desc  limit 40",40,24,0}]
  2. <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a>
  3. [/e:loop]
复制代码
方式4(和上面的相同,只是sql格式有稍微不同)
  1. [e:loop={"select a.*,b.* from [!db.pre!]enewstags a LEFT JOIN [!db.pre!]enewstagsdata b ON a.tagid=b.tagid where classid=3 group by b.tagid order by a.num desc limit 100",0,24,0}]
  2. <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a>
  3. [/e:loop]
复制代码
注释:classid = 3 为栏目ID(新闻ID)必须为终极栏目
1、上面的为调用单个栏目
2、多个栏目时,修改“classid = 3”为 classid in(4,5,6,7)
3、调用当前栏目(列表、内容通用):把 “ classid = 3”  替换为  “ classid='$GLOBALS[navclassid]' ”






上一篇:帝国cms灵动标签多条件调用
下一篇:帝国CMS列表页面模板 如何调用栏目ID