我可以在Shopify模板中成功添加第二个硬编码store address
。现在,我尝试添加第二个address
。
我面临的挑战是这个硬编码地址正在重复,因为for
循环绑定了settings.json
文件中的值。
硬编码地址重复三次,因为for循环正在考虑它。但是for
循环无法删除,因为它会绑定第一个地址,联系人和访问时间。
我尝试使用if
块和我的硬编码,但它没有用完。
这是我的代码:
<div class="container main content main-wrapper">
{% if section.settings.image == nil %}
<h1 class="center">{{ page.title }}</h1>
<div class="feature_divider"></div>
{% endif %}
<div class="sixteen columns featured_links">
<div class="section clearfix feature">
{% for block in section.blocks %}
<div class="{% if section.settings.featured_promos_per_row == 2 %}eight columns {% cycle 'alpha', 'omega' %}{% elsif section.settings.featured_promos_per_row == 3 %}one-third column {% cycle 'alpha', '', 'omega' %}{% else %}four columns {% cycle 'alpha', '', '', 'omega' %}{% endif %} {% if section.settings.featured_links_style != blank %}{{ section.settings.featured_links_style }} {% cycle 'delay-025s', 'delay-05s', 'delay-075s', 'delay-1s' %}{% endif %} center">
{% if block.settings.link != blank %}
<a href="{{ block.settings.link }}">
{% endif %}
<div class="{% if section.settings.rounded_image != blank %}rounded{% endif %}">
{% if block.settings.image != nil %}
<img src="{{ block.settings.image | img_url: '300x' }}"
alt="{{ block.settings.image.alt }}"
data-src="{{ block.settings.image | img_url: '2048x' }}"
class="lazyload"
{% comment %} data-sizes="auto" {% endcomment %}
data-srcset=" {{ block.settings.image | img_url: '2048x' }} 2048w,
{{ block.settings.image | img_url: '1600x' }} 1600w,
{{ block.settings.image | img_url: '1200x' }} 1200w,
{{ block.settings.image | img_url: '1000x' }} 1000w,
{{ block.settings.image | img_url: '800x' }} 800w,
{{ block.settings.image | img_url: '600x' }} 600w,
{{ block.settings.image | img_url: '400x' }} 400w"
/>
{% else %}
{% capture i %}{% cycle "1", "2", "3", "4", "5", "6" %}{% endcapture %}
{{ 'collection-' | append: i | placeholder_svg_tag: 'placeholder-svg placeholder-svg--promotions' }}
{% endif %}
</div>
{% if block.settings.title != blank %}
<h3>{{ block.settings.title | escape }}</h3>
{% if section.settings.show_divider %}
<div class="feature_divider"></div>
{% endif %}
{% endif %}
{% if block.settings.link != blank %}
</a>
{% endif %}
{% if block.settings.text != blank %}
{{ block.settings.text }}
{% endif %}
{% if section.blocks===1%}
<div class="store-new">
<br><p>XYZ</p><p>XYZ,<br>XYZ<br>XYZ</p>
</div>
{% endif %}
</div>
{% if section.settings.featured_promos_per_row == 2 %}
{% cycle '', '<br class="clear " />' %}
{% elsif section.settings.featured_promos_per_row == 3 %}
{% cycle '', '', '<br class="clear" />' %}
{% else %}
{% cycle '', '', '', '<br class="clear" />' %}
{% endif %}
{% endfor %}
</div>
{% if section.settings.contact_address != blank %}
<br class="clear" />
<div class="embed-container maps">
<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q={{ section.settings.contact_address | replace: ' ', '+' }}&z={{ section.settings.zoom_level }}&output=embed"></iframe>
</div>
{% endif %}
</div>
</div>
有人可以帮我理解为什么会这样吗?
答案 0 :(得分:3)
你可以使用
android:background="@drawable/selector"
或
{{ if forloop.index0 == 1 }}
而不是
{{ if forloop.index == 2 }}