I’d like to list page sections in a Select field so I can anchor to them, for example:
About - Intro
About - History
About - Team
Services - Intro
Services - Overview
Contact - Overview
Contact - Form
I’m currently trying to get my head around how best to do this and was wondering if it’s possible with just a query? The anchor points are in the CMS as a field ‘type: headline’ to help the user, is there any way I can use these in a query? Or is my approach totally wrong?
Where do these sections come from? Are they subpages? Sections from a builder field? Or just single fields/groups of fields?
Single fields. Would it be best to set them up as subpages? Or is it possible with my current setup?
If each section is a field, why don’t you use the field names as anchors? I’m missing to see the purpose of the select field
Potentially sections can be added with a Builder field (only on one page though). Hardcoding them is an option I guess, but is there a way these Builder sections could be listed?
I think I don’t really understand what you are trying to achieve. But if you want the user to be able to sort or select certain sections, I’d use the builder field or subpages rather then hardcoded fields.
Sorry for my poor explanation. I have a button on the page, the link of which can be set in the CMS. The link isn’t just to a page though, it could be ‘page.html#anchor’, for example. So I’d link to dynamically make all pages and possible anchors available to the user (I thought a Select would be the best way to do this). Seems like subpages for the sections is the best way to go, if I can’t query all headline fields per page (which was my original thinking).
You could query the headline fields with a custom model method, but do you actually use these headlines in your frontend? Otherwise, it would be pretty useless.
While this applies to the frontend, you can use the same query in a custom method:
I need to rethink my approach, as the headlines don’t apply to things added in a Builder field anyway. Thank you (as always) for getting me thinking differently, @texnixe !