I have a featured collection section on the home page set by default to “All” Collection. I have a list of custom buttons in a custom liquid section. Each button needs to change the featured collection to another collection.
Can someone point me in the right direction? Is it possible to change the collection dynamically? Also, I do mean change the actual collection, not heading, etc, etc.
I am dupplicating an existing non-Shopify site, otherwise I wouldn’t do it this way!
1 Like
Thank you for the feedback, but I am not asking about the creation of collections.
I am asking whether it is possible to change the collection that a “collection section” is currently displaying on the main page using liquid?
1 Like
A bit late for the question, but recently solved a similar task and decided to leave some info for Shopify Developers who look for a solution.
Section Rendering API can be used in context of different pages, so if you use the given section on a home page and it has buttons for selecting another collection, you could fetch that section in the context of a clicked collection with URL similar to `const fetchUrl = /collections/${collectionHandle}?section_id=${this.sectionId};`
To make it return first collection outside the collection context, you may use a condition similar to
```
if collection == blank or collection.handle == blank
assign collection = section.settings.collection_list | first
endif
```
This way it would render the first collection on home page, but return HTML for another collection while being fetched via Section Rendering API.
Section using this mechanism would not work as expected if placed on Collection Page, I assume.