Shopify themes, liquid, logos, and UX
I am using linklists to display structured content on a page. I need an extra level of hierarchy than shopify navigation allows. So I have one linklist (list1) that is a single level deep and has all of the top level categories with an additional corresponding linklist for each item in list1. The handle for each corresponding linklist matches the link handle for each item in list1
I have been trying to write a loop that renders a link in list1 then uses the handle from that link to call the linklist that corresponds to it and render the appropriate links, children, and grandchildren.
The snippet i'm using to call the corresponding linklist works when hardcoded but doesn't work when I try to pass it a variable. The handles for all the related linklist have been double checked and I've also confirmed that the variable handle is being passed to the snippet.
code on the page:
<ul class="menu top-level"> {% for link in linklists.list1.links %} <li class="menu-link"> <a href="{{ link.url }}">{{ link.title }}</a> {% assign listhandle = link.handle %} {% include "linklist" with linklistHandle: listhandle %} </li> {% endfor %} </ul>
code in a linklist snippet:
{% for link in linklists[linklistHandle].links %}
<li class="menu-link">
<a href="{{ link.url }}">{{ link.title }}</a>
...
bump
I ran into something similar where a handle I knew was correct wasn't indexing properly into the linklists object. I think there is some sort of bug on shopify's side because I worked around it by running my handle through the downcase filter. This should obviously do nothing but doing the equivalent of the following:
{% assign listhandle = link.handle | downcase %}:
fixed the problem for me.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024