Show section (ID) references in the url schema setting
Is your feature request related to a problem? Please describe. We do have some clients that wants a section with links to certain sections on the page. This is not easily possible at the moment. We have to make a section with blocks where they can add a block and then add an ID to the section they want to link to. I was trying to add a "#" to the url settings and hoped to find a hidden gem. What I hoped is that I could receive a list of the existing sections / id's on that page where I could link to.
Describe the solution you'd like I Actually already described what I'd like to see. A reference to the existing section / id's on the page. I can imagine that finding ID's will be a bit hard, but section do have their own generated id's that I would like to reference to.
Describe alternatives you've considered Create a text setting per section where the client can fill in an ID. Also create a setting on the link blocks where they can add the same value (ref to ID). The problem with this, is that this would not be bug-free and consistent enough. It will bloat all sections that don't necessarily need this field.
Checklist
- [x] I have checked and made sure that the proposal adheres to this plugin's principles
👋 Hi @stijns96, thanks for the suggestion!
If I'm understanding the proposal correctly, I believe we may close https://github.com/Shopify/theme-tools/issues/474 in favor of this one, as we could have something like this:
{% for section in sections %}
{{ section.id }}
{{ section.group_id }}
{% endfor %}
Please let me know what you think :)
Hi @karreiro,
Sure thing!
Not sure if sections on itself is clear enough. You might need to know what group you want to loop through, or if it's just the content_for_layout.
When I was thinking about the sections, I was thinking about something like this to handle https://github.com/Shopify/theme-tools/issues/474:
{% assign header_group_sections = sections | where: 'group_id', 'header-group' %}
{% # ^-- group identifier %}
{% for section in sections %}
{{ section.id }}
{% endfor %}
However, one limitation of the example above is that users need to know the group identifier in advance (the current group).
With the section_group object/drop (proposed by https://github.com/Shopify/theme-tools/issues/474), sections would always be aware of their parent group (if available), allowing them to iterate over it.
I'm going to bring this context to the team for discussion and will update this issue as soon as we have something new :)
Thanks bringing this up!
Mhhh,
That would be hard indeed. What about something like sections['header-group']? Then we're taking away a bit of logic, but I'm not sure if this is technically possible.
👋 Hey @stijns96,
I don't think that would be possible because the sections['header-group'] syntax implies the presence of a header-group property on sections that is an array.
I will close this in favor of https://github.com/Shopify/theme-tools/issues/474 for now.
Please, feel free to add new comments here or there, if you spot something that prevents us from evolving in that direction.
Thanks for bringing this up!