【问题标题】:Shopify if NOT homepage?Shopify 如果不是主页?
【发布时间】:2018-06-19 07:20:46
【问题描述】:

如何检测 shopify if Homepage?以前有一个处理程序是page.frontpage,现在不再使用了。

我需要从主页中排除某些内容,因此无法编辑index.liquid 文件。

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    我们可以这样做:

    {% if template.name != "index" %} 
     do something
    {% endif %}
    

    【讨论】:

    • 这会检查它是否不是主页。请参阅 @brenthack35 的答案以获得可行的解决方案。
    【解决方案2】:

    要检测主页,您应该使用双等号“==”,感叹号“!=”的使用是发现所有“不”等于“索引”。

    {% if template.name == "index" %}
        do something
    {% endif %}
    

    【讨论】:

      【解决方案3】:

      我是这样使用的:

          {% if template.name != "index" %}
            do something
          {% endif %}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-16
        相关资源
        最近更新 更多