PbootCMS 模板常用的if条件判断语句

COS、CDN
  • 问题:PbootCMS模板常用的if条件判断语句。
  • 答案
    • 导航高亮
      html
       
      {pboot:if('[nav:scode]'=='{sort:tcode}')}class="active"{/pboot:if}
    • 判断有无子菜单
      html
       
      {pboot:if([nav:soncount]>0)}...{/pboot:if}
    • 二级栏目循环判断
      html
       
      {pboot:nav} <li><a href="[nav:link]">[nav:name]</a> {pboot:if([nav:soncount]>0)} <div>{pboot:2nav parent=[nav:scode]}<a href="[2nav:link]">[2nav:name]</a>{/pboot:2nav}</div> {/pboot:if} </li> {/pboot:nav}
    • 判断是否链接赋值
      html
       
      {pboot:nav} <li><a {pboot:if([nav:soncount]>0)}href="javascript:;"{else}href="[nav:link]"{/pboot:if}>[nav:name]</a></li> {/pboot:nav}
    • 内页子菜单高亮
      html
       
      {pboot:if('[nav:scode]'=='{sort:scode}')}class="active"{/pboot:if}
    • 判断标签为空时不显示
      html
       
      {pboot:if('{pboot:companyqq}'!='')}QQ:{pboot:companyqq}{/pboot:if}
    • 判断列表页有无内容
      html
       
      {pboot:if({page:rows}>0)}{page:bar}{else}暂无内容{/pboot:if}
    • 分页判断进阶
      html
       
      {pboot:if({page:rows}>0)} <div class="page"> <a href="{page:index}" {pboot:2if('{page:current}'==1)}class="hide"{/pboot:2if}>首页</a> <a href="{page:pre}" {pboot:2if('{page:current}'==1)}class="hide"{/pboot:2if}>上一页</a> {page:numbar} <a href="{page:next}" {pboot:2if('{page:current}'=='{page:count}')}class="hide"{/pboot:2if}>下一页</a> <a href="{page:last}" {pboot:2if('{page:current}'=='{page:count}')}class="hide"{/pboot:2if}>尾页</a> </div> {else} <div class="page">暂无内容</div> {/pboot:if}
    • 判断第一个循环项并添加 class
      html
       
      {pboot:if('[xx:i]'=='1')}class="active"{/pboot:if}
    • 内容页判断有无多图
      html
       
      {pboot:if({content:ispics}==1)}...多图...{else}...缩略图...{/pboot:if}
    • 内容页判断列表中的当前文章高亮
      html
       
      {pboot:if('[list:link]'=='{content:link}')}class="active"{/pboot:if}
    • 奇偶数判断
      html
       
      {pboot:if([list:i]%2==0)}...{/pboot:if}
    • 判断导航从第几个开始
      html
       
      {pboot:if('[nav:i]'>2)}...{/pboot:if}
    • 隐藏指定 scode 的菜单
      html
       
      {pboot:if([nav:scode]==2||[nav:scode]==4||[nav:scode]==6)}style="display: none;"{/pboot:if}
COS、CDN
热门