shopify - Forloop 打破了布局
问题描述
我有从元字段中获取的这些数据。我遇到的问题是循环破坏了我的布局,我似乎可以弄清楚
<div class="sidekick-body">
<div class="accordion">
<article>
{% for entry in shop.metafields.navigation.collection_structure %}
{% assign entry = entry | json %}
{% if entry.parent == block.settings.collection-handle %}
{% if entry.rank == 2 %}
<!-- </article>
<article> -->
<div class="header">
<a href="/collections/{{ entry.handle }}">
{{- entry.title | replace: '\', '' -}}
</a>
<i class="fas fa-chevron-down"></i>
</div>
<div class="panel">
<ul class="mobile-nav">
{% else %}
<li><a href="/collections/{{ entry.handle }}" class="mobile-nav-item mobile-nav-item-subcategory">{{- entry.title | replace:
'\',
'' -}}</a></li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</div>
</article>
</div>
</div>
这很好用,没有手风琴
<article>
{% for entry in shop.metafields.navigation.collection_structure %}
{% assign entry = entry | json %}
{% if entry.parent == block.settings.collection-handle %}
{% if entry.rank == 2 %}
<div class="header">
<a href="/collections/{{ entry.handle }}">
{{- entry.title | replace: '\', '' -}}
</a>
<i class="fas fa-chevron-down"></i>
</div>
{% else %}
<!-- <div class="panel"> -->
<ul class="mobile-nav">
<li>
<a href="/collections/{{ entry.handle }}" class="mobile-nav-item mobile-nav-item-subcategory">
{{- entry.title | replace:'\','' -}}
</a>
</li>
</ul>
<!-- </div> -->
{% endif %}
{% endif %}
{% endfor %}
</article>
但我需要手风琴,我的设计需要手风琴,否则页面会太长,不利于用户体验
解决方案
推荐阅读
- wordpress - 创建 PayPal 帐户不是可选的
- c - 在 Android Studio 项目中使用 libsndfile
- swift - 如何同步两个不同单元格宽度的集合视图的水平滚动?
- powershell - 通过脚本运行时无法在 new-smbshare 中添加多个组
- integromat - 在 Integromat 应用程序中实现异步 API 端点
- mysql - SQL 从多个组中获取均匀分布的值
- typescript - 如何获取重载方法/多态方法的第 n 个参数的类型?
- security - 如何在 AWS EKS 中使用 istio 网格启用自动 mTLS?
- node.js - 在 Google Identity Platform 中插入多个用户 - Nodejs / React
- reactjs - 在 React 中,如何处理包含状态的数组?