Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Created August 28, 2012 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyhuey/3494014 to your computer and use it in GitHub Desktop.
Save andyhuey/3494014 to your computer and use it in GitHub Desktop.
alter a view query
<?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