Change the default argument view for taxonomy/term when the argument is not passed

Last modified: June 28, 2008 - 18:44

If you want to change the default argument view for taxonomy_term, and make it show the empty text when the argument is passed, or an unsorted summary when no argument is passed, just enter the following code in the Argument Code textfield:

<?php
if ($args[0] != '') {
 
$view->argument[0]['argdefault'] = '7';
}
else {
 
$view->argument[0]['argdefault'] = '3';
}
$view->is_cacheable = 0;

return
$args;
?>

The list of the possible values is the following:

  • 1 - Return Page Not Found
  • 2 - Display All Values
  • 3 - Summary, unsorted
  • 4 - Summary, sorted ascending
  • 5 - Summary, sorted descending
  • 6 - Summary, sorted as view
  • 7 - Empty Empty Text

It works just for the first time

Kiam@avpnet.org - June 28, 2008 - 18:51

It seems to work just for once.
If you access http://example.com/taxonomy/term, and then http://example.com/taxonomy/term/78 (where 78 is the id of a term which is not used to tag any nodes), it will work; if you then access http://example.com/taxonomy/term/78, you will not get the expected result.

-- Kiam@AVPnet

 
 

Drupal is a registered trademark of Dries Buytaert.