Created
September 11, 2014 14:26
-
-
Save gregmercer/1453c8687f5ae8258ef6 to your computer and use it in GitHub Desktop.
hook_views_pre_execute example
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
/** | |
* Implements hook_views_pre_execute(). | |
*/ | |
function gsb_feature_news_display_views_pre_execute(view &$view) { | |
if ($view->name == 'news_two') { | |
dpm($view); | |
$query1 = &$view->build_info['query']; | |
dpm($query1); | |
dpm($query1->getFields()); | |
$query2 = db_select('node', 'n'); | |
$query2->leftJoin('field_data_field_region_of_interest', 'rgn' | |
, '(n.nid = rgn.entity_id AND rgn.deleted = :parameter)', array(':parameter' => '0')); | |
$query2 | |
->condition('type', array('announcement'), 'IN') | |
->condition('field_region_of_interest_tid', '26551', '=') | |
->condition('status', 1, '='); | |
$query2->addField('n', 'title', 'node_title'); | |
$query2->addField('n', 'nid', 'nid'); | |
$query2->addField('n', 'created', 'node_created'); | |
$query1 = $query2->union($query1, 'UNION ALL'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment