Skip to content

Instantly share code, notes, and snippets.

@croxton
Last active April 8, 2018 02:22
Show Gist options
  • Save croxton/1084483 to your computer and use it in GitHub Desktop.
Save croxton/1084483 to your computer and use it in GitHub Desktop.
Sort on a Playa custom field in ExpressionEngine [HACK]
<?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