You are here

function i18n_menu_query_preferred_menu_links_alter in Internationalization 7

Implements hook_query_TAG_alter()

Using tag 'preferred_menu_links' added in menu_link_get_preferred(). See http://drupal.org/node/1854134

File

i18n_menu/i18n_menu.module, line 930
Internationalization (i18n) submodule: Menu translation.

Code

function i18n_menu_query_preferred_menu_links_alter(QueryAlterableInterface $query) {
  global $language;

  // Get queried tables.
  $tables = $query
    ->getTables();
  foreach ($tables as $alias => $table) {
    if ($table['table'] == 'menu_links') {

      // Add language filter, ensuring that we don't have any collision when
      // determining the active menu trail when there are multiple menu items
      // with same link path but different languages.
      if ($language) {
        $query
          ->condition('language', array(
          $language->language,
          LANGUAGE_NONE,
        ), 'IN');
      }
      break;
    }
  }
}