home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_handler_argument_null.inc)

This example Drupal source code file (views_handler_argument_null.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

arg, args, array, empty, form, form_state, function, if, parent::default_actions, php, return, unset, validation, which

The views_handler_argument_null.inc Drupal example source code

// $Id: views_handler_argument_null.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
 * Argument handler that ignores the argument.
class views_handler_argument_null extends views_handler_argument {
  function option_definition() {
    $options = parent::option_definition();
    $options['must_not_be'] = array('default' => FALSE);
    return $options;

   * Override options_form() so that only the relevant options
   * are displayed to the user.
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['must_not_be'] = array(
      '#type' => 'checkbox',
      '#title' => t('Fail basic validation if any argument is given'),
      '#default_value' => !empty($this->options['must_not_be']),
      '#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),


   * Override default_actions() to remove actions that don't
   * make sense for a null argument.
  function default_actions($which = NULL) {
    if ($which) {
      if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
        return parent::default_actions($which);
    $actions = parent::default_actions();
    unset($actions['summary asc']);
    unset($actions['summary desc']);
    return $actions;

  function validate_argument_basic($arg) {
    if (!empty($this->options['must_not_be'])) {
      return !isset($arg);

    return parent::validate_argument_basic($arg);

   * Override the behavior of query() to prevent the query
   * from being changed in any way.
  function query() {}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_argument_null.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.