-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entry ordering - any interest? #475
Comments
Ooh, that sounds cool. One aspect to consider is how differently different site generators handle order. I would think you would want to set per collection whether the drag-to-order function is enabled, and also to specify the field name to be set by the dragging. |
@gausie ordering is definitely something the CMS needs! I think the approach will be a little different - it's laid out in the designs under #179. I believe steps toward this will look something like this:
This would bypass drag and drop, but would allow entries to be sorted by any field. You could then implement a custom ordering field if you wanted to set order manually. Thoughts? |
@erquhart Those improvements all sound awesome (especially #2!), but I think what @gausie is referring to is changing the field that determines post order in the site output, not in the CMS listing. For example, like we use the 'position' field in the CMS docs to set a custom order for pages. When adding or moving a page, it's a hassle to go into the existing files, determine what position they are, choose a number that fits between them, and adjusting the surrounding page positions if there isn't enough room left between them. Being able to do this in the UI via drag-and-drop (or up/down arrow buttons) would be a huge convenience improvement. There are a few implementation details that could be tricky, though, like how exactly to handle that number shuffling when necessary. I also wonder if it makes sense to handle the drag-and-drop ordering directly in the post view, or to put it in a different view, or perhaps a different "mode" in the same view (e.g. click an "Edit item order" button to reveal arrow buttons and make items draggable, then click "Save" commit changes and exit the mode). |
Ah, good point, thanks for clarifying. Considerations:
There's more, but I think these are the biggies. The value of the feature is apparent, but it's important to avoid adding complexity to the UI. To answer the original question, we're definitely interested! Just need to agree on the right approach before moving forward. |
I would really appreciate a PR for this gausie. I've been doing sorting outside of the CMS since it doesn't currently have it, but within the CMS is definitely the best place for it to happen. |
I've been thinking about this idea as well, and I have an idea of possible implementation Folder collections in particular (since data ones already have sorting) have an optional "ordered: " property that enables the dragging functionality on the collection's screen. The value for this property would determine what key the numeric order will be saved as in the file- for example: "ordered: order" would make every file in the collection have a hidden "order" key that stores the number of their position. I'm not sure how it should interact if the ordered option is specified and the same key is added into the fields. I might try my hand at this but complex Javascript is not my forte. |
@rogermparent how would you handle updating all files? For example, let's say I have fifty entries in a collection, and they all have a number value in their I'm definitely not meaning to discourage you, just want to make sure we're tackling the real problem before you invest time. Ideally we could just store order info in a single file per collection and update that, but static site generators don't roll like that. Thoughts? |
@erquhart I'm not familiar with how the GitHub API works, I didn't know it was an individual call for each file. I suppose if you want to cut down on this you'd need an external source of ordering, which necessitates having a sort of "primary key" on the ordered files to reference them by- I think filenames are a viable candidate, as they're implicitly unique and present in all static site generators without extra work from the user. |
Solid response, thanks for that! This would work, but basically boils down to an extra build step where the order parameter is added to each frontmatter based on filename and a data file containing the order. Which is better than not offering this at all. Makes me wonder how much else can be done through an extra build step, and how we can make these bits easy to implement. |
Would be a big step forward just to allow for some control over the order items are displayed in. At the moment it's effectively arbitrary. Could Guess what I'm trying to say is that displaying a collection's entries in order is separate from managing those items' order. I can see how the latter is tough, but the former feels like it should be much easier to achieve … |
Agreed. There's a similar issue with more info, and the real challenge is outlined in a comment there: #54 (comment) tl;dr: paginated endpoints are a challenge. But we could do it easily enough with GitHub. Sent with GitHawk |
Update: this doesn't have to be that difficult, actually. We're certainly not ready for a PR on it, as there still needs to be a plan of attack for the design, but I just realized we don't need to have a bunch of API calls for this to work. We would need all entries in a collection loaded, but that's already the case for other existing features, such as search. The key will be performing the sort update in a single commit. It would touch an arbitrary number of entries in a collection, potentially all of them, but the logic for performing the change just shouldn't be that difficult. What bears consideration is how to introduce this functionality to the CMS when we have no existing method for changing multiple entries in a single commit. |
I've been lurking around a solution for this and found my own work around for who might be interested. 1 - setup a new collection for ordering Not ideal but it gives my client the ability to use the drag and drop feature of the list widget.
Not very clean but it works for me 😉Hopefully someone more clever is gonna bring this to life in a PR |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
stop it stale bot |
Quiet around these parts, any chance of this being implemented in the near future? |
Hi @ed-omr, we use up votes for prioritization, you can visit this link to see the most up voted issues. |
I definitely agree that the cleaner solve is a separate file storing ordering information. We don't want unreadable diffs on PRs. |
@theredwillow That's a nice idea! I found an example of reordering selected items with
I think this issue is actually about sorting the order of entries inside a collection, not changing the order of collections in the sidebar. |
+1 : would really like to see this feature |
How can I set this up with an 11ty site? I dont have an index.js and I cant really figure out where to put it or how to reference it to make it work (the list and the sorting works fine, but it does not update the value I need - in my case it is "order_on_page" for entries located in the "src/review" folder |
So this is the second most requested feature for the CMS and after 7 years it is still nowhere??? |
Hi @adambernath the best way to move this forward is to submit a pull request. |
I'd be happy to write a PR that makes entries on the collection page draggable if there is an "order" field on that collection, and the order of the dragged elements would be reflected in said field.
This would allow most CMSs to then order entries by that order value and thus give us custom ordering.
Would such a feature likely be accepted?
The text was updated successfully, but these errors were encountered: