Using Linklists and menu structure in logic?

Outer_net_
Shopify Partner
8 0 4

Does anyone know if it is possible to do something like this to allow the filter Vendor label to change based on the collection / sub > sub collection hierarchy ? Obviously that would be based on the established Menu and linklist " collection- " function I have in place for the menu handles.

 

I feel like there should be an easier way to do this !

https://water-street-gallery.myshopify.com/collections/art

 

Pass = wsg

 

 

 

{% comment %}Start of the vendor filter block with dynamic vendor label and filtering{% endcomment %}
{% elsif block.type == 'filter_by_vendor' %}
<summary>
  <h4 class="sidebar-block__heading">
    {% assign collection_handle = collection.handle %}
    {% assign vendor_label = 'Artist & Maker' %} <!-- Default Label -->
    {% assign main_menu = linklists['main-menu'] %} <!-- Assuming 'main-menu' contains your collection hierarchy -->
    
    {% for link in main_menu.links %}
      {% if link.object %}
        {% if link.object.handle == collection_handle %}
          {% assign vendor_label = 'Artist' %} <!-- Direct match with top-level collection -->
        {% elsif link.object.handle contains 'collection-' %}
          {% assign sub_collection_handle = link.object.handle | remove: 'collection-' %}
          {% if sub_collection_handle == collection_handle %}
            {% assign vendor_label = 'Artist' %} <!-- Adjust based on sub-collection logic -->
          {% endif %}
        {% endif %}
      {% endif %}
    {% endfor %}
    
    {{ vendor_label }}
    <span class="right icon-down-arrow sidebar-block-toggle-icon"></span>
  </h4>
</summary>
<ul class="toggle_list">
  {% assign collection_products = collections[collection.handle].products %}
  {% assign filtered_vendors = collection_products | map: 'vendor' | uniq %}
  
  {% for vendor in filtered_vendors %}
    <li class="{% if vendor == collection.title %}active{% endif %} data-active-legacy-filter">
      <a href="{{ shop.url }}/collections/{{ collection.handle }}?vendor={{ vendor | handleize }}">{{ vendor }}</a>
    </li>
  {% endfor %}
</ul>
Replies 0 (0)