PbootCMS 模板常用的if条件判断语句
- 问题: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}
- 导航高亮:

扫码添加技术【解决问题】
专注企业网站建设、网站安全16年。
承接:企业网站建设、网站修改、网站改版、BUG修复、问题处理、二次开发、PSD转HTML、网站被黑、网站漏洞修复等。
专业解决各种疑难杂症,您有任何网站问题都可联系我们技术人员。
本文来自博客园,作者:黄文Rex,转载请注明原文链接:https://www.cnblogs.com/hwrex/p/18509854

浙公网安备 33010602011771号