Replies: 3 comments 3 replies
-
|
Sorry, posted this through the wrong account, so deleted and reposting: I think the most flexible way to handle a channel/structure's section's index is using a single entry. AFAIK this is what most devs are doing (or using an entry type in a structure), though it's not perfect. We're just missing a way to nest sections like:
IMO if you could nest a section under a single you would cover most of your points:
I think it all boils down to this: We need better ways to place a section within the whole content model. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Finally, I should note that as of Craft 5, with the Though that doesn't cover all bases and I haven't tried it with very large sections or complex models, so I'm not sure of all potential drawbacks to this approach. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I realized that the user can use the link field to link to individual entries but not to entire sections. But that's a feature that I need. That made me realize that in my templates I also link to a section's index page statically like
<a href="/blog">Blog</a>because I don't know of a more programmatic way to do so. That made me think...What if sections (or basically channels and structures) had an index URL and index template just like they do have an entry URL and entry template? That would give us multiple benefits:
{{ section.url }}.sectionvariable just like entry templates receive anentryvariable. It would make accessing a sections URL, name, entries, and other things a bit easier. I don't know, wouldcraft\models\Sectionbe a suitable type for this? It would need a new property or function to access the new URL. And is there currently a way to query a section object itself? I know of{{ craft.entries().section(name) }}, but that doesn't work here because it just returns a list of entries. Instead there should be something like{{ craft.section(name) }}, unless there's already an API that I don't know yet.sectionvariable from point 3 could have acpEditUrlvariable. Now, sections already have such a variable but they link to the settings page that's meant to be used by admins (Settings > Sections > Some Section), while entries have the same variable which links to the edit page that's meant to be used by editors (Entries > Some Section > Some Entry). I currently need to manually construct the URL that leads to the section edit page for editors (Entries > Some Section) like this:'/admin/entries/' ~ currentSection.handle ~ '?source=section%3A' ~ currentSection.uid, all while using custom Twig functions to actually get thecurrentSectionvariable.In general, this would reduce some repetition in your templates when it comes to a section itself which also reduces the amount of work in a refactoring. E.g.:
{{ craft.entries().section('blog').all() }}would become{{ craft.entries().section(section).all() }}(EDIT: or maybe even{{ section.entries().all() }}).EDIT:
Beta Was this translation helpful? Give feedback.
All reactions