Adding "All Collections" to collection list options

Adding "All Collections" to collection list options

rpaulpen
Tourist
11 0 3

Hi All,

Shopify 2.0, dawn, trying to add a option for "All Collections" in the collections list. It only allows to list a specific collection whereas I would like a selection where all collections show up.  I assume code has to be added to the collection-list-liquid file but could some help.  Something along the lines of: if collection field is left blank, default to "all collections"

 

Any help is appreciated.

RP

Replies 4 (4)

ProtoMan44
Shopify Partner
640 55 97

@rpaulpen Hey, thanks for posting here.

can you please use this method:

{% assign selected_collections = section.settings.collections %}

{% if selected_collections.size > 0 %}
  <!-- Show selected collections -->
  {% for collection in selected_collections %}
    <div class="collection-item">
      <a href="{{ collection.url }}">
        <img src="{{ collection.image | img_url: 'medium' }}" alt="{{ collection.title }}">
        <h3>{{ collection.title }}</h3>
      </a>
    </div>
  {% endfor %}
{% else %}
  <!-- Show all collections if no specific collection is selected -->
  {% for collection in collections %}
    <div class="collection-item">
      <a href="{{ collection.url }}">
        <img src="{{ collection.image | img_url: 'medium' }}" alt="{{ collection.title }}">
        <h3>{{ collection.title }}</h3>
      </a>
    </div>
  {% endfor %}
{% endif %}

 

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!
rpaulpen
Tourist
11 0 3

Thank you for your reply. Not quite what I was thinking.  This loads all the collections if left blank wheres what I want is the normal collection list but the one left blank should have a link to the "all collections" rather than a specific collection.   

rpaulpen
Tourist
11 0 3

Looking at this closer, the code seems to be in card-collection.liquid. Maybe my description is not clear.  All I want in the collection card is to be able to select "All collections" instead of a specific collection.  Looking at the attached image, it would take user to same place as the "View All" button does.  Assuming the easiest way would be to default to "view all" if left blank.Screenshot 2024-12-19 at 9.59.00 AM.png

ProtoMan44
Shopify Partner
640 55 97

@rpaulpen does not understand it.

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!