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

Drupal example source code file (content_plugin_display_simple.inc)

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

alias, array, class, content_plugin_display_simple, empty, extends, function, isset, like, match_clauses, options, php, return, uses_exposed

The content_plugin_display_simple.inc Drupal example source code

<?php
// $Id: content_plugin_display_simple.inc,v 1.1.2.5 2010/06/09 04:10:25 karens Exp $

/**
 * @file
 * Handler for 'content_simple' display.
 */
class content_plugin_display_simple extends views_plugin_display {
  function execute() {
    return $this->view->render($this->display->id);
  }

  function render() {
    return !empty($this->view->result) || !empty($this->view->style_plugin->definition['even empty']) ? $this->view->style_plugin->render($this->view->result) : '';
  }

  function uses_exposed() {
    return FALSE;
  }
}

class content_plugin_display_references extends content_plugin_display_simple {
  function query() {
    $options = $this->get_option('content_options');

    if ($options['string'] !== '') {
      $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE";
      $match_clauses = array(
        'contains' => "$like '%%%s%%'",
        'equals' => "= '%s'",
        'starts_with' => "$like '%s%%'",
      );
      $clause = isset($match_clauses[$options['match']]) ? $match_clauses[$options['match']] : $match_clauses['contains'];
      $alias = $this->view->query->ensure_table($options['table']);
      $this->view->query->add_where(NULL, "$alias.$options[field_string] $clause", $options['string']);
    }
    elseif ($options['ids']) {
      $alias = $this->view->query->ensure_table($options['table']);
      $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']);
    }
  }
}

Other Drupal examples (source code examples)

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