Skip to content

Instantly share code, notes, and snippets.

@driesd
Created September 17, 2013 10:31
Show Gist options
  • Save driesd/6592607 to your computer and use it in GitHub Desktop.
Save driesd/6592607 to your computer and use it in GitHub Desktop.
Adds the language filter condition to taxonomy term views
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"
<?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