adjusting the dataCategories sortParentChild function
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 5 Jul 2017 16:09:25 +0000 (12:09 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 5 Jul 2017 16:09:25 +0000 (12:09 -0400)
the parentChild sorting function in the dataCategories data class file needed to add the
tilde appended to not just the parent but the child as well in order to properly sort
categories that are similar in name except for numbers or characters at the end

classes/data/dataCategories.php

index eabf097..aa4dd0b 100644 (file)
@@ -403,25 +403,24 @@ class GlmDataEventsCategories extends GlmDataAbstract
         if (!is_array($array) || count($array) == 0) {
             return false;
         }
-
+        
         // Do a sort by custom function with it included in the call
         // This lets me directly use $name and $parent in the sort function
         uasort($array, function ($a, $b) use ($name, $parent) {
-
             // If there's a parent, append the name of this entry to the parent
             // The '~~~' simply keeps appended strings from any chance of a match with something else
             if ($a[$parent]['value']) {
                 $aVal = $a[$parent]['name'].'~~~'.$a['name'];
             } else {
                 // Otheriwse just use the name.
-                $aVal = $a['name'];
+                $aVal = $a['name'].'~~~';
             }
 
             // Same for b value
             if ($b[$parent]['value']) {
                 $bVal = $b[$parent]['name'].'~~~'.$b['name'];
             } else {
-                $bVal = $b['name'];
+                $bVal = $b['name'].'~~~';
             }
 
             if ($aVal > $bVal) {