Created
August 28, 2012 01:02
-
-
Save andyhuey/3494014 to your computer and use it in GitHub Desktop.
alter a view query
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 | |
/** | |
* implements hook_query_alter(). | |
*/ | |
function MY_MODULE_query_alter(QueryAlterableInterface $query) { | |
if ($query->hasAllTags('views', 'views_university_search')) { | |
$ord =& $query->getOrderBy(); | |
if (array_key_exists('location_country', $ord)) { | |
$query->addJoin('INNER', 'countries_country', 'cc', 'cc.iso2 = location.country'); | |
$ord = array('cc.name' => $ord['location_country']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment