Shopify themes, liquid, logos, and UX
Hi,
My company website is https://onparshop.com/collections
I'm trying to modify the "Featured Collections" tablist which does what I want of filtering the collection within the same URL. What I'd like to achieve is adding pictures to each of the texts.
This is the code I need to edit based on what I can gather; however, I'm having a hard time modifying it to include both a photo and text as my filter buttons.
Any thoughts regarding what to change to have the buttons include picture and text?
{%- if section.blocks.size > 1 -%} <div class="SectionHeader__TabList TabList" role="tablist"> {%- for block in section.blocks -%} {%- assign collection = collections[block.settings.collection] -%} <button class="Heading u-h1 TabList__Item {% if forloop.first %}is-active{% endif %}" data-action="toggle-tab" aria-controls="block-{{ block.id }}" aria-selected="{% if forloop.first %}true{% else %}false{% endif %}" role="tab"> {%- if collection != empty -%} {{- block.settings.title | default: collection.title -}} {%- else -%} {{- 'home_page.onboarding.collection_title' | t -}} {%- endif -%} </button> {%- endfor -%}
Solved! Go to the solution
This is an accepted solution.
Hi,
You can use the collection image as the image.
Here is the sample code.
{%- if section.blocks.size > 1 -%}
<div class="SectionHeader__TabList TabList" role="tablist">
{%- for block in section.blocks -%}
{%- assign collection = collections[block.settings.collection] -%}
<button class="Heading u-h1 TabList__Item {% if forloop.first %}is-active{% endif %}" data-action="toggle-tab" aria-controls="block-{{ block.id }}" aria-selected="{% if forloop.first %}true{% else %}false{% endif %}" role="tab">
{% if collection.image %}
<img src="{{ collection | img_url: '50x50' }}" alt="{{ collection.image.alt }}" />
{% else %}
<img src="{{ collection.products.first | img_url: '50x50' }}" alt="{{ collection.title | escape }}" />
{% endif %}
{%- if collection != empty -%}
{{- block.settings.title | default: collection.title -}}
{%- else -%}
{{- 'home_page.onboarding.collection_title' | t -}}
{%- endif -%}
</button>
{%- endfor -%}
</div>
Please don't hesitate to reach out if you need further help optimizing or customizing your store. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!
Best Regards,
LuffyOnePiece
This is an accepted solution.
Hi,
You can use the collection image as the image.
Here is the sample code.
{%- if section.blocks.size > 1 -%}
<div class="SectionHeader__TabList TabList" role="tablist">
{%- for block in section.blocks -%}
{%- assign collection = collections[block.settings.collection] -%}
<button class="Heading u-h1 TabList__Item {% if forloop.first %}is-active{% endif %}" data-action="toggle-tab" aria-controls="block-{{ block.id }}" aria-selected="{% if forloop.first %}true{% else %}false{% endif %}" role="tab">
{% if collection.image %}
<img src="{{ collection | img_url: '50x50' }}" alt="{{ collection.image.alt }}" />
{% else %}
<img src="{{ collection.products.first | img_url: '50x50' }}" alt="{{ collection.title | escape }}" />
{% endif %}
{%- if collection != empty -%}
{{- block.settings.title | default: collection.title -}}
{%- else -%}
{{- 'home_page.onboarding.collection_title' | t -}}
{%- endif -%}
</button>
{%- endfor -%}
</div>
Please don't hesitate to reach out if you need further help optimizing or customizing your store. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!
Best Regards,
LuffyOnePiece
Learn what's possible with customizing Shopify Checkout beyond what's available out of...
By Shopify Feb 19, 20252m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025