Created
September 17, 2013 10:31
-
-
Save driesd/6592607 to your computer and use it in GitHub Desktop.
Adds the language filter condition to taxonomy term views
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
name = The AIM - Views term language | |
description = Fix / Add the language filter to taxonomy term views | |
core = 7.x | |
package = "Custom" | |
dependencies[] = "views" | |
dependencies[] = "views_ui" | |
dependencies[] = "i18n_taxonomy" |
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 | |
/** | |
* @file | |
* Fix / Add the language filter to taxonomy term views | |
*/ | |
/** | |
* Add language filter to views | |
*/ | |
function custom_termview_langfix_views_query_alter(&$view, &$query) { | |
if($view->base_table == 'taxonomy_term_data') { | |
if((bool)$view->display[$view->current_display]->handler->options['field_language_add_to_query'] && $view->display[$view->current_display]->handler->options['field_language'] !== 'und') { | |
$query->where[] = array( | |
'conditions' => array(array( | |
'field' => 'taxonomy_term_data.language', | |
'value' => array($view->display[$view->current_display]->handler->options['field_language']), | |
'operator' => 'in', | |
)), | |
'args' => array(), | |
'type' => 'AND', | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment