Created
August 12, 2014 19:39
-
-
Save haroldSanchezb/a657ac1665853901b70e to your computer and use it in GitHub Desktop.
pre execute query views drupal 7
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 | |
function cableonda_sports_photogallery_views_pre_execute(view &$view) { | |
if ($view->name == 'photogallery_by_activity') { | |
if($view->current_display =='block_1'){ | |
$query = $view->build_info['query']; | |
$query2 = db_select('node', 'a')->fields('a',array('nid')); | |
$query2->addField('a', 'created', 'node_created'); | |
$query2->addExpression("'node'", 'field_data_field_photo_imagen_node_entity_type'); | |
$query2->addExpression("'photogallery_by_activity:block_1'", 'view_name'); | |
$query2->leftJoin("field_data_field_photo_reference", "b", "a.nid = b.entity_id AND (b.entity_type = 'node' AND b.deleted = '0') "); | |
$query2->where("(( (a.nid != '".$view->args[0]."' OR a.nid IS NULL) AND (b.field_photo_reference_target_id = '".$view->args[1]."' ) ) AND (( (a.status = '1') AND (a.type IN ('photo')) )))"); | |
$view->build_info['query'] = $query->union($query2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment