Posted by freeform.steph on September 10, 2010 at 3:04pm
By default, taxonomy pages display content in chronological order, and this is not customizable unless you update the core module.
To get around this, create a view with taxonomy term as the argument, simple (if you're new to views and arguments, check-out this tutorial video: http://gotdrupal.com/videos/drupal-views-arguments).
In the argument settings, if you enter %1 as the title override, the page title will become the Taxonomy term of the taxonomy id argument, BUT this method fails to show the translated string if you're not viewing the page in the default language.
To get around this, instead of using the argument title override, use php in your view's header setting:
<?php
// get language properties of current language
global $language;
$lang = $language->language;
// get the argument from view and get the term properties
$view = views_get_current_view();
$tid = $view->args[0];
$term = taxonomy_get_term($tid);
// if term exists, get term name in current language
if($term){
$name = $term->name;
$mytitle = tt("taxonomy:term:{$tid}:name", $name, $lang,FALSE);
}
else {
// provide a default title if no argument was given, replace "default_title" with desired title
$mytitle = t(default_title);
}
print "<h1 class='title'>".$mytitle."</h1>";
?>
Comments
Where can I find my 'views header section' ?
I have the same problem, but I cannot find the place where to apply this modification? Where can I find theis 'view's header setting'?
Thank you !
After upgrading to views version 6.x-3.x-rc2 my header code:
<?phpdrupal_set_title(t(drupal_get_title()));
?>
did not work anymore.
But yours does !
Update, 27 april 2012:
I have changed
<?phpprint "<h1 class='title'>".$mytitle."</h1>";
?>
to
<?php$view->build_info['title'] = $mytitle;
?>
Now the html title tag in the page source is correctly filled.