• 帝国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
     3 if(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>[/e:loop]
     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><?=$bqr[ztname]?></u></a></li>[/e:loop]
     9 <?php }
    10 else 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="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
    12 <?php }
    13 else 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]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
    15 <?php }
    16 else 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]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
    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行会将带“软”、“器”、“下载”、“音乐”的数据调出......

  • 相关阅读:
    Python中的浅复制、深复制
    Python
    CSS中
    Fluent_Python_Part3函数即对象,05-1class-func,一等函数,函数即对象
    Python
    本地简单HTTP服务器
    Fluent_Python_Part2数据结构,04-text-byte,文本和字节序列
    Fluent_Python_Part2数据结构,03-dict-set,字典和集合
    Fluent_Python_Part2数据结构,02-array-seq,序列类型
    Codeforces 246E Blood Cousins Return(树上启发式合并)
  • 原文地址:https://www.cnblogs.com/chig/p/11757920.html
Copyright © 2020-2023  润新知