我正在尝试根据用户查看特定网页的时间启用div类,例如: blog、index或../ page /webpage
代码如下:
{% unless template contains "index" and settings.slideshow_enabled %}
<div class="container main content">
{% endunless %}该“容器主要内容”在导航栏后面显示了一个图像。在其他页面上,图像从导航栏下方开始。这里有一个明显的例子:http://retina-theme.myshopify.com/
我想有相同的主页,链接上面的链接,在选定的页面或模板:
{% if template == "index" and template == "page" and settings.slideshow_enabled %}
<div class="container main content">
{% endif %}到目前为止,我没有尝试过任何有效的方法。有什么建议吗?
编辑:
到目前为止,我还不能回答我自己的问题,但这是通过对javascript进行调整来实现的:
{% unless template contains "page" or template contains "index" and settings.slideshow_enabled %}
<div class="container main content">
{% endunless %}发布于 2014-06-29 07:11:52
if语句中的多个条件在liquid中不能很好地工作。See a similar question here。
一种选择是使用嵌套的if语句:
{% if template == "index" or template == "page" %}
{% if settings.slideshow_enabled %}
<div class="container main content">...</div>
{% endif %}
{% endif %}或者类似这样的东西:
{% if template == "index" or template == "page" %}
{% assign correct_template = true %}
{% endif %}
{% if correct_template and settings.slideshow_enabled %}
<div class="container main content">...</div>
{% endif %}https://stackoverflow.com/questions/24468229
复制相似问题