Community Documentation

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

Last updated June 28, 2008. Created by kiamlaluno on June 28, 2008.
Log in to edit this page.

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

Comments

It works just for the first time

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

Kiam
Kiam la luno renkontas la sunon

About this page

Drupal version
Drupal 5.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.