Support custom ordering for Entries fields with Maintain hierarchy enabled #17352
Unanswered
MoritzLost
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Entries fields with the Maintain hierarchy option enabled show selected entries in the hierarchy defined in the structure of the target section, and ensures that all ancestors of all selected entries are also selected.
But the option also enforces that all selected entries have the same sort order as the section structure, which can be a problem. Sometimes, you want to ensure that parent entries are always selected (for sorting, filtering, etc), but you still need a way to arrange entries in a different order. For example, to prioritize the selected entries relative to the current entry.
There are workarounds for this, like using two separate entries fields, or working around it in code, but none of those are great in terms of AX / UX / DX.
I can think of two ways to improve this:
Sorting within the structure levels
Not sure about technical implications, but from an author's perspective, it would be ideal if they could rearrange selected entries within the structure hierarchy. In the screenshot above, I could swap the position of Parent A and Parent B, taking their children with them. Or swap the position of Child A1 and Child A2, but not move them to a different parent. Child B1 could not be moved.
Adding parent entries in a flat list
Add a second option, or have a dropdown of three behavior variants. One would be the existing behavior, which fills any gaps in the structure, displays entries in a hierarchy and prevents rearranging them. But there would be a behavior in between that's closer to an Entries field without Maintain hierarchy. Entries would be displayed in a flat list and can be rearranged, but every time entries are selected or the entry is saved, any missing parents are added to the end of the list.
This would ensure that all ancestors of all selected entries are also related, but still allow a custom sort order.
I've build this functionality in a module because I needed it for a project, here's a proof of concept:
Beta Was this translation helpful? Give feedback.
All reactions