Last active
April 8, 2018 02:22
-
-
Save croxton/1084483 to your computer and use it in GitHub Desktop.
Sort on a Playa custom field in ExpressionEngine [HACK]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Look for this in mod.channel.php (around line 2635): | |
case 'custom_field' : | |
if (strpos($corder[$key], '|') !== FALSE) | |
{ | |
$end .= "CONCAT(wd.field_id_".implode(", wd.field_id_", explode('|', $corder[$key])).")"; | |
} | |
else | |
{ | |
$end .= "wd.field_id_".$corder[$key]; | |
} | |
break; | |
// And change to: | |
/* change start ---> */ | |
case 'custom_field' : | |
if (strpos($corder[$key], '|') !== FALSE) | |
{ | |
$end .= "CONCAT(wd.field_id_".implode(", wd.field_id_", explode('|', $corder[$key])).")"; | |
} | |
else | |
{ | |
$is_playa = FALSE; | |
$site_id = ee()->config->item('site_id'); | |
if ( isset ($this->pfields[$site_id][$corder[$key]])) | |
{ | |
if ( $this->pfields[$site_id][$corder[$key]] == 'playa') | |
{ | |
$is_playa = TRUE; | |
} | |
} | |
// do we have a playa field | |
if ( $is_playa ) | |
{ | |
$end .= "SUBSTRING(wd.field_id_".$corder[$key].", (LOCATE(']', wd.field_id_".$corder[$key].")+1))"; | |
} | |
else | |
{ | |
$end .= "wd.field_id_".$corder[$key]; | |
} | |
} | |
break; | |
/* <--- change end */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment