Created
July 10, 2014 09:59
-
-
Save mrded/979b5b07d36df2649ec8 to your computer and use it in GitHub Desktop.
Drupal 7: Overwrite views on the fly
This file contains hidden or 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_views_pre_view(). | |
*/ | |
function HOOK_views_pre_view(&$view, &$display_id, &$args) { | |
if ($view->name == 'company_contents') { | |
$company_node = menu_get_object(); | |
if (!empty($company_node->field_contract_period[LANGUAGE_NONE][0])) { | |
$filters = $view->display_handler->get_option('filters'); | |
$filters['created'] = array( | |
'id' => 'created', | |
'table' => 'node', | |
'field' => 'created', | |
'operator' => 'between', | |
'value' => array( | |
'min' => $company_node->field_contract_period[LANGUAGE_NONE][0]['value'], | |
'max' => $company_node->field_contract_period[LANGUAGE_NONE][0]['value2'], | |
'type' => 'date', | |
) | |
); | |
$view->display_handler->override_option('filters', $filters); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment