如何在液体中添加IF语句的活跃课程(shopify)
我在标题内有2个链接(一个链接将您带到一个商店,另一个链接将您带到另一家商店)。我需要在用户开设的商店中添加一个活动类(BMX商店& skate商店是需要添加活动类的两个类别的类)。因此,如果用户在BMX商店中,则该商店的链接变为大胆和下划线,反之亦然。
{% if request.url contains 'source-bmx-testing.myshopify.com' %}
{% elsif request.url contains 'sourceskate.myshopify.com' %}
{% endif %}
我知道该代码需要与上面的摘要相似,但不确定如何将其添加到代码中,我必须根据您的使用者将活动类添加到商店中。以下是我的代码:
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'bmx-link' -%}
<a class="link-container" href="{{ block.settings.store_link }}">
<div class="bmx-store">
<img
width="15"
height="15"
src="{{ block.settings.icon_image | img_url: '15x15' }}"
srcset="{{ block.settings.icon_image | img_url: '15x15' }}"
alt="{{ block.settings.icon_image.alt }}">
<span>{{ block.settings.store_link_title }}</span>
</div>
</a>
{%- when 'skate-link' -%}
<a class="link-container" href="{{ block.settings.store_link }}">
<div class="skate-store">
<img
width="15"
height="15"
src="{{ block.settings.icon_image | img_url: '15x15' }}"
srcset="{{ block.settings.icon_image | img_url: '15x15' }}"
alt="{{ block.settings.icon_image.alt }}">
<span>{{ block.settings.store_link_title }}</span>
</div>
</a>
{%- endcase -%}
{%- endfor -%}
I have 2 links inside the header (one link takes you to one stores the other link takes you to another store). I need to add an active class to the store the user is on (bmx-store & skate-store are the 2 classes that need active class adding to). So if the user is on the bmx store, the link for that store becomes bold and underlined and vice versa.
{% if request.url contains 'source-bmx-testing.myshopify.com' %}
{% elsif request.url contains 'sourceskate.myshopify.com' %}
{% endif %}
I know the code needs to be similar to the snippet above but not sure how to add it into the code i have to add the active class to the store depending on which one you are on. Below is my code:
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'bmx-link' -%}
<a class="link-container" href="{{ block.settings.store_link }}">
<div class="bmx-store">
<img
width="15"
height="15"
src="{{ block.settings.icon_image | img_url: '15x15' }}"
srcset="{{ block.settings.icon_image | img_url: '15x15' }}"
alt="{{ block.settings.icon_image.alt }}">
<span>{{ block.settings.store_link_title }}</span>
</div>
</a>
{%- when 'skate-link' -%}
<a class="link-container" href="{{ block.settings.store_link }}">
<div class="skate-store">
<img
width="15"
height="15"
src="{{ block.settings.icon_image | img_url: '15x15' }}"
srcset="{{ block.settings.icon_image | img_url: '15x15' }}"
alt="{{ block.settings.icon_image.alt }}">
<span>{{ block.settings.store_link_title }}</span>
</div>
</a>
{%- endcase -%}
{%- endfor -%}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果商店有2个以上的其他清洁液。
If stores are more than 2 other cleaner solutions can be found.