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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection sort does not fallback on localized values 馃嚚馃嚟 #1520

Closed
rrelmy opened this Issue Jul 24, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@rrelmy

rrelmy commented Jul 24, 2017

Expected behaviour

{{ collection sort="title" }} should fallback to the default title if the localization does not have a title.

Actual behaviour

It does not fallback to the default and sorts based on a lot of null values

Steps to reproduce

  1. Create a localized collection
  2. Do not add localized titles
  3. Try to output them sorted in the secondary locale

Server Details

Statamic Version: 2.6.1

Fix with hacking the core

Statamic\Data\DataCollection->getSortableValues uses $a->get( changing it to getWithDefaultLocale fixes the issue.

Index: statamic/core/Data/DataCollection.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- statamic/core/Data/DataCollection.php	(revision aa7d324133c9a67a886e5c2b6648e770d58f49f6)
+++ statamic/core/Data/DataCollection.php	(revision )
@@ -77,8 +77,8 @@
     {
         $method = Str::camel($sort);
 
-        $one = (method_exists($a, $method)) ? call_user_func([$a, $method]) : $a->get($sort);
-        $two = (method_exists($b, $method)) ? call_user_func([$b, $method]) : $b->get($sort);
+        $one = (method_exists($a, $method)) ? call_user_func([$a, $method]) : $a->getWithDefaultLocale($sort);
+        $two = (method_exists($b, $method)) ? call_user_func([$b, $method]) : $b->getWithDefaultLocale($sort);
 
         return [$this->normalizeSortableValue($one), $this->normalizeSortableValue($two)];
     }

@rrelmy rrelmy changed the title from Collection sort does not fallback on localized values to Collection sort does not fallback on localized values :switzerland: Jul 24, 2017

@rrelmy rrelmy changed the title from Collection sort does not fallback on localized values :switzerland: to Collection sort does not fallback on localized values 馃嚚馃嚟 Jul 24, 2017

@subpixelch

This comment has been minimized.

subpixelch commented Aug 10, 2017

@jasonvarga fixed in next release? :-) low hanging fruit

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Aug 10, 2017

Done! Thanks for bumping this, and for the fix.

@jasonvarga jasonvarga closed this Aug 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment