Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How to show and expand all filters on collection pages by default?

Solved

How to show and expand all filters on collection pages by default?

Platypyrus
Excursionist
16 0 4

On a collections page, I want to show ALL of the filters and expand all accordions. (Dawn theme)

 

I have tried the solutions previously given but I can't get them working or I can't find where to add the code.

 

Screenshot 2024-07-17 at 5.07.06 PM.png

Accepted Solution (1)
Sweans
Shopify Partner
428 88 126

This is an accepted solution.

Hi @Platypyrus ,

Great to hear that you were able to figure it out by searching for forloop.index on the page and using the similar code you found!

To display all the options without Show More/Show Less and to remove these links, you’ll need to remove certain code from the facets.liquid file.


1. To display all options:

You can search for the following code in the file and remove it from the code:

{% if forloop.index > show_more_number and filter_type ==
 'vertical' %} show-more-item hidden{% endif %}


Note: removing these class names will let you display all options of the filter menu

2. To remove all Show More/Show Less links:

You can search for following code in the file and remove it from the code:

{%- if filter.values.size > show_more_number and filter_type == 'vertical' -%}
<show-more-button>
<button
class="button-show-more link underlined-link no-js-hidden"
id="Show-More-{{ forloop.index }}-{{ section.id }}"
type="button">
<span class="label-show-more label-text"
><span aria-hidden="true">+ </span>{{ 'products.facets.show_more' | t -}}
</span>
<span class="label-show-less label-text hidden"
><span aria-hidden="true">- </span>{{ 'products.facets.show_less' | t -}}
</span>
</button>
</show-more-button>
{%- endif %}

 

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

View solution in original post

Replies 5 (5)

AnneLuo
Shopify Partner
1138 211 235

Hi, @Platypyrus 

I can help you with it. So I need to access your store as a collaborator if possible. 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me   

Buy Me A Coffee

Sweans
Shopify Partner
428 88 126

Hi @Platypyrus,

Step - 1: Go to your store admin > Sale channels > Online store

Step - 2: Navigation to Themes > click "..." in Trade theme > Edit code

Sweans_0-1721276032384.png

 



Step - 3: In the edit code, search for “facets.liquid” and open the file

Step - 4: In “facets.liquid” file, you can find the following code: (line - 367, which can vary depending on the version of the theme)

 

<details id="Details-{{ forloop.index }}-{{ section.id }}" class="{% if filter_type == 'horizontal' %}disclosure-has-popup facets__disclosure{% else %} facets__disclosure-vertical{% endif %} js-filter" data-index="{{ forloop.index }}" {% if filter_type == 'vertical' and forloop.index == 1 %} open {% endif %}>

 


Step - 5: In the above-mentioned code, replace the “if” condition with the “open” attribute to expand all filters. (You can remove the above code and paste the below-mentioned instead) Eg:

 

<details id="Details-{{ forloop.index }}-{{ section.id }}" class="{% if filter_type == 'horizontal' %}disclosure-has-popup facets__disclosure{% else %} facets__disclosure-vertical{% endif %} js-filter" data-index="{{ forloop.index }}" open>

 


Step 6: Save the file and reload your collection page, you’ll see all filters expanded on the collection page.

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

Platypyrus
Excursionist
16 0 4

Ok, facets.liquid was helpful but I didn't have a "details id". I was however, able to search the page for "forloop.index" and I found some similar code and was able to figure it out from there.

 

To finish this up, I would just need to get rid of the "Show More / Show Less" link since it will be useless now. 

Sweans
Shopify Partner
428 88 126

This is an accepted solution.

Hi @Platypyrus ,

Great to hear that you were able to figure it out by searching for forloop.index on the page and using the similar code you found!

To display all the options without Show More/Show Less and to remove these links, you’ll need to remove certain code from the facets.liquid file.


1. To display all options:

You can search for the following code in the file and remove it from the code:

{% if forloop.index > show_more_number and filter_type ==
 'vertical' %} show-more-item hidden{% endif %}


Note: removing these class names will let you display all options of the filter menu

2. To remove all Show More/Show Less links:

You can search for following code in the file and remove it from the code:

{%- if filter.values.size > show_more_number and filter_type == 'vertical' -%}
<show-more-button>
<button
class="button-show-more link underlined-link no-js-hidden"
id="Show-More-{{ forloop.index }}-{{ section.id }}"
type="button">
<span class="label-show-more label-text"
><span aria-hidden="true">+ </span>{{ 'products.facets.show_more' | t -}}
</span>
<span class="label-show-less label-text hidden"
><span aria-hidden="true">- </span>{{ 'products.facets.show_less' | t -}}
</span>
</button>
</show-more-button>
{%- endif %}

 

If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

Platypyrus
Excursionist
16 0 4

It worked perfectly, thanks for the help!!!