Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

FR: Ability to change the sort_dir for number based collections #1210

Closed
rrelmy opened this issue Jan 30, 2017 · 1 comment
Closed

FR: Ability to change the sort_dir for number based collections #1210

rrelmy opened this issue Jan 30, 2017 · 1 comment

Comments

@rrelmy
Copy link

rrelmy commented Jan 30, 2017

Due to customers with special needs it would be nice to be able to change the sort direction of number based collections like the date based.

It is not documented but on date based collections you can specify the direction with the option sort_dir inside the collections folder.yaml but the direction for number based collections is hardcoded.

Here is a simple achieve that.
Update: This patch breaks reordering!

Index: statamic/core/Http/Controllers/EntriesController.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- statamic/core/Http/Controllers/EntriesController.php	(date 1485789228000)
+++ statamic/core/Http/Controllers/EntriesController.php	(revision )
@@ -52,6 +52,7 @@
             $sort_order = $collection->get('sort_dir', 'desc');
         } elseif ($collection->order() === 'number') {
             $sort = 'order';
+            $sort_order = $collection->get('sort_dir', 'asc');
         }
 
         $reorderable = $collection->order() === 'number' && $collection->count() <= Config::get('cp.pagination_size');

@jackmcdade
Copy link
Member

Added for next release!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants