i18ntaxonomy_views_pre_view

Versions
5
i18ntaxonomy_views_pre_view(&$view, &$items)

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

Code

contributions/i18n/contrib/i18ntaxonomy.module, line 127

<?php
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';
      }
    }
  }

}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.