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

Drupal example source code file (views_plugin_argument_default_node.inc)

This example Drupal source code file (views_plugin_argument_default_node.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, as, extends, foreach, function, get_argument, if, is_numeric, node, php, return, views_plugin_argument_default, views_plugin_argument_default_node

The views_plugin_argument_default_node.inc Drupal example source code

<?php
// $Id: views_plugin_argument_default_node.inc,v 1.1.6.1 2010/01/28 22:44:36 dereine Exp $
/**
 * @file
 * Contains the node from URL argument default plugin.
 */

/**
 * Default argument plugin to extract a node via menu_get_object
 *
 * This plugin actually has no options so it odes not need to do a great deal.
 */
class views_plugin_argument_default_node extends views_plugin_argument_default {
  function get_argument() {
    foreach (range(1, 3) as $i) {
      $node = menu_get_object('node', $i);
      if (!empty($node)) {
        return $node->nid;
      }
    }

    if (arg(0) == 'node' && is_numeric(arg(1))) {
      return arg(1);
    }
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_plugin_argument_default_node.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.