代码之家  ›  专栏  ›  技术社区  ›  atsngr

用一个条件和多个值协调If语句

  •  1
  • atsngr  · 技术社区  · 8 年前

    我编写这段代码是为了将breadcrumb从某些Prestashop 1.7页面中删除,它可以正常工作。然而- $page.page_name -重复出现对我来说并不合适,尤其是如果我打算将面包屑从其他网页中删除的话。目前,索引和订单确认页面已被豁免,我将添加更多。

    {if $page.page_name != 'index' && $page.page_name != 'order-confirmation'}
                                    {include file='_partials/breadcrumb.tpl'}
                                {/if}
    

    请建议是否有更好更精确的方法来编写此代码。我尝试了下面的代码,但没有成功:

    {if $page.page_name != 'index, order-confirmation'}
                                    {include file='_partials/breadcrumb.tpl'}
                                {/if}
    
    1 回复  |  直到 8 年前
        1
  •  3
  •   Alessandro Minoccheri    8 年前

    您可以使用以下内容:

    {if !in_array($page.page_name, array('index','order-confirmation'), true) }
        {include file='_partials/breadcrumb.tpl'}
    {/if}