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

Drupal example source code file (views_plugin_argument_default_php.inc)

This example Drupal source code file (views_plugin_argument_default_php.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

argument, array, code, for, form, function, php, radio:options, raw, result, return, this, use, value

The views_plugin_argument_default_php.inc Drupal example source code

// $Id: views_plugin_argument_default_php.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
 * @file
 * Contains the php code argument default plugin.

 * Default argument plugin to provide a PHP code block.
class views_plugin_argument_default_php extends views_plugin_argument_default {
  var $option_name = 'default_argument_php';

  function argument_form(&$form, &$form_state) {
    $form[$this->option_name] = array(
      '#type' => 'textarea',
      '#title' => t('PHP argument code'),
      '#default_value' => $this->get_argument(TRUE), // the true forces it raw.
      '#process' => array('views_process_dependency'),
      '#description' => t('Enter PHP code that returns a value to use for this argument. Do not use <?php ?>. You must return only a single value for just this argument.'),
      '#dependency' => array(
        'radio:options[default_action]' => array('default'),
        'radio:options[default_argument_type]' => array($this->id)
      '#dependency_count' => 2,


   * Only let users with PHP block visibility permissions set/modify this
   * default plugin.
  function access() {
    return user_access('use PHP for block visibility');

  function get_argument($raw = FALSE) {
    if ($raw) {
      return parent::get_argument();

    // set up variables to make it easier to reference during the argument.
    $view = &$this->view;
    $argument = &$this->argument;
    $result = eval($this->argument->options[$this->option_name]);
    return $result;

Other Drupal examples (source code examples)

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