Change default order to LIFO?
The default behavior is that a new item goes to the bottom of the list -- i.e., it gets the highest number. Is there a way to change that, so whenever you create a new item is goes to the top of the list?
The default behavior is that a new item goes to the bottom of the list -- i.e., it gets the highest number. Is there a way to change that, so whenever you create a new item is goes to the top of the list?
Replies
Low 5 Oct 2010 21:20
Not in the control panel, but you could achieve it in your templates by setting the sort attribute: sort="desc"
bkalbfeld 5 Oct 2010 21:40
Thanks. It's a great module, but I'm not sure which would be more confusing for the editor -- having to move newer items to the top of the queue or seeing the entire queue upside down. Would you consider making this a new feature in a future release?
Low 5 Oct 2010 21:47
Sure, I'd definitely consider it. Would it help if you could define a sorting value to the channel/field pair settings? Setting it to 'ascending' would add new entries to the bottom and you'd use sort="asc" in the channel:entries tag. Setting it to 'descending' would add new entries to the top and you'd use sort="desc" in the channel:entries tag.
bkalbfeld 5 Oct 2010 22:18
I don't think so, because it sounds like that would break the connection between the list of the entries in the module and the way they'd show up in the template.
The module always wants to display the entries in the order they will be displayed in the template -- otherwise the user will be confused. So that feels like it always wants to be sort="asc". since the module always displays entries in ascending order.
As a result, the global setting would be whether new entries default to the top of the list or the bottom.
My initial thought was a global setting of setting of "descending" would mean a new entry gets a low_reorder_field value of n+1. The user would see the new entry at the bottom of the list.
"Ascending" would mean that a new entry's low_order_field would be given a value of 1 and all the existing low_order_fields would be incremented (which would be the biggest issue, I assume). In the module, the user would see the new entry at the top of the list.
I think that makes sense ...
Low 6 Oct 2010 06:28
I hear you. I'll add it to the list of things to implement. Thanks for your input.
Low 7 Oct 2010 07:51
Check out version 1.0.5. I think this will suit your needs.
bkalbfeld 7 Oct 2010 15:10
Thanks. One question: is the upgrade process the same as a new install? Will it know the fields already exist?
Low 7 Oct 2010 15:32
Yes, just overwrite the files and go to the module. The upgrade happens automatically.
bkalbfeld 7 Oct 2010 16:00
OK, done. It works well. Thank you! One thing that is not intuitive -- and that you might want to mention in the doc -- is that the numbering in the field does not match the numbers a user sees when working in the module's display screen (when reordering entries). In other words, in the "descending" mode, the item that shows at the top of this list in the control panel display -- with the number 1 -- is actually the last item in the list, which is why the template's entries tag has to sort "desc". It took me a few minutes to get my head around that.
Low 8 Oct 2010 07:36
I thought about making this a setting. I probably will in a next version. You could also use the {count} variable in your channel:entries tag to display the correct number in your templates.