I’m creating a liquid theme following the Horizon theme pattern.
Is there a way to override the title and image of each collection from closest.collection so that users can use custom titles and images (not necessarily using the default title or image from collection.title but can also use block.settings.title for example)
Hey @renova :waving_hand. Hopefully I’m understanding correctly here, but you should be able to override collection titles and images using block settings while maintaining fallbacks to the default properties.. The default filter, does allows you to specify a fallback value when a setting is empty, false, or nil.
In your Liquid template you should be able to use a pattern like: block.settings.custom_title | default: collection.title to display the custom setting when provided, or fall back to the collection’s default title when the setting is empty.
Can you let me know if this works for you or if you encounter any issues? Happy to look into this further if needed - hope this helps!
I thought that if we add a title field in the “collection card” block, it will be applied to all cards (all cards will have the same title). What I want is for each card title to be overridable with a different title. I usually use a different block (section block) for each collection and place the title field there. I don’t think closest.* was designed for that.
I’ve found a solution, with a theme block pattern like horizon, without using closest.collection.
Thanks for clarifying @renova! I see what you mean now, sorry for the misunderstanding there.
You’re right that with the default pattern, a single title field in the “collection card” block would technically then apply the same title to all cards. Using separate blocks for each collection is a valid approach to get this set up for sure.
You’re correct that closest.* wasn’t designed for that specific use case. It’s primarily meant for accessing the nearest resource context when blocks are nested or when iterating through collections (like when looping through products in a collection grid).
Thanks for following up with your findings, I’ll mark this as solved for now, but if I can clarify anything on our end, just let me know. Your workaround will for sure help other folks out, so thanks for replying and sharing here