帝国CMS模板中的多条件筛选⽅法
需求:点击某⼀条⽬,调出与该条⽬关键词相关的类似词条数据
要点:
1.帝国CMS灵动标签使⽤[e:loop=
2.专题关键词筛选 enewszt
3.SQL语句筛选 select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%下载%
4.随机排序 order by rand()
5.PHP 判断字符串存在 strpos($title,'下载') !== false
1 <ul>
2 <?php
3if(strpos($title,'下载') !== false)
4 {?>
5 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%下载%' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[
帝国cms教程网6 <?php
7 }else if(strpos($title,'软件') !== false){?>
8 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%件%' or ztpagekey like '%器%' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=
9 <?php }
10else if(strpos($title,'仓库') !== false){?>
11 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%管理%' or ztpagekey like '%仓库%' or ztpagekey like '%系统%' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=
12 <?php }
13else if(strpos($title,'器') !== false){?>
14 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%软%' or ztpagekey like '%器%' or ztpagekey like '%下载%' or ztpagekey like '%⾳乐%' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" targ
15 <?php }
16else if(strpos($title,'⼤全') !== false){?>
17 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' and ztpagekey like '%全%' or ztpagekey like '%器%' or ztpagekey like '%系统%' or ztpagekey like '%软件%' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" targ
18 <?php }else{?>
19 [e:loop={"select * from [!db.pre!]enewszt where zcid='$zr[zcid]' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
20 <?php }?>
21 </ul>
说明:当点击下载器;第5⾏会将带“下载”字符串的数据调出;同时,因为带“器”,第14⾏会将带“软”、“器”、“下载”、“⾳乐”的数据调出......
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论