Translate titles in a view drupal

Posted by: 
Dominique De Cooman

Translate a views title
Copy the theme_views_view function which you find in your views.module file and put it in your template.php file. (Dont forget to change theme into phptemplate). Add this line on top

drupal_set_title(t($view->title));

The function to put in php template should look like this:
/**
 * Display a view.
 */
function phptemplate_views_view($view, $type, $nodes, $level = NULL, $args = NULL) {
  drupal_set_title(t($view->title));
  $num_nodes = count($nodes);
 
  if ($type == 'page') {
    drupal_set_title(filter_xss_admin(views_get_title($view, 'page')));
    views_set_breadcrumb($view);
  }
 
  if ($num_nodes) {
    $output .= views_get_textarea($view, $type, 'header');
  }
 
  if ($type != 'block' && $view->exposed_filter) {
    $output .= views_theme('views_display_filters', $view);
  }
 
  $plugins = _views_get_style_plugins();
  $view_type = ($type == 'block') ? $view->block_type : $view->page_type;
  if ($num_nodes || $plugins[$view_type]['even_empty']) {
    if ($level !== NULL) {
      $output .= "<div class='view-summary ". views_css_safe('view-summary-'. $view->name) ."'>". views_theme($plugins[$view_type]['summary_theme'], $view, $type, $level, $nodes, $args) . '</div>';
    }
    else {
      $output .= "<div class='view-content ". views_css_safe('view-content-'. $view->name) ."'>". views_theme($plugins[$view_type]['theme'], $view, $nodes, $type) . '</div>';
    }
    $output .= views_get_textarea($view, $type, 'footer');
 
    if ($type == 'block' && $view->block_more && $num_nodes >= $view->nodes_per_block) {
      $output .= theme('views_more', $view->real_url);
    }
  }
  else {
    $output .= views_get_textarea($view, $type, 'empty');
  }
 
  if ($view->use_pager) {
    $output .= theme('pager', '', $view->pager_limit, $view->use_pager - 1);
  }
 
  if ($output) {
    $output = "<div class='view ". views_css_safe('view-'. $view->name) ."'>$output</div>n";
  }
  return $output;
}

Add new comment

Who are you?


By knowing who you are you will be directed to a page where we have displayed all our drupal services relevant to your professional identity.