帝国CMS模板制作中需要调用指定栏目中所有数据包含的TAG或者当前栏目中所有数据包含的TAG,使用如下方法即可实现(最后有代码说明):
方法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 = 34 order by [!db.pre!]enewstags.num DESC limit 30",0,24}] <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a> [/e:loop]
方法2、(和上面的相同,只是sql格式有稍微不同)
[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=34 group by tagid order by num desc limit 40",40,24,0}] <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a> [/e:loop]
方法3、(和上面的相同,只是sql格式有稍微不同)
[e:loop={"select a.*,b.* from [!db.pre!]enewstags a,[!db.pre!]enewstagsdata b where a.tagid=b.tagid and classid=34 group by b.tagid order by a.num desc limit 40",40,24,0}] <a href='<?=$public_r['newsurl']?>e/tags/?tagname=<?=$bqr['tagname']?>' title='<?=$bqr['num']?>个'><?=$bqr['tagname']?>(<?=$bqr['num']?>)</a> [/e:loop]
方法4、(和上面的相同,只是sql格式有稍微不同)
[e:loop={"select a.*,b.* from [!db.pre!]enewstags a LEFT JOIN [!db.pre!]enewstagsdata b ON a.tagid=b.tagid where classid=34 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]
注:classid = 34 为栏目ID(国内新闻ID)必须为终极栏目
1、上面的为调用单个栏目
2、多个栏目时,修改“classid = 34”为 classid in(34,35,36,37)
3、调用当前栏目(列表、内容通用):把 “ classid = 34 ” 替换为 “ classid='$GLOBALS[navclassid]' ”
评论前必须登录!
立即登录 注册