You are here

function i18ntaxonomy_views_pre_view in Internationalization 5.3

Same name and namespace in other branches
  1. 5 contrib/i18ntaxonomy.module \i18ntaxonomy_views_pre_view()
  2. 5.2 contrib/i18ntaxonomy.module \i18ntaxonomy_views_pre_view()

Implementation of hook_views_pre_view().

Translate table header for taxonomy fields //field[i][id] = term_node_1.name, translate table header and replace handler for that field

File

contrib/i18ntaxonomy.module, line 127
Internationalization (i18n) package - taxonomy term translation

Code

function i18ntaxonomy_views_pre_view(&$view, &$items) {

  //var_dump($view);
  $translate = variable_get('i18ntaxonomy_vocabularies', array());
  foreach ($view->field as $index => $data) {
    $matches = array();
    if ($data['id'] == 'term_node.name') {

      // That's a full taxonomy box
      $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
    }
    elseif (preg_match("/term_node_(\\d+)\\.name/", $data['id'], $matches)) {
      $vid = $matches[1];
      if ($translate[$vid]) {

        // Set new handler for this field
        $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
      }
    }
  }
}