Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Created August 28, 2012 01:02
Show Gist options
  • Select an option

  • Save andyhuey/3494014 to your computer and use it in GitHub Desktop.

Select an option

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