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

Drupal example source code file (relcontext_from_simplecontext.inc)

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

array, conf, context, ctools_relcontext_from_simplecontext_context, ctools_relcontext_from_simplecontext_settings_form, description, function, new, null, php, relcontext, return, simplecontext, title

The relcontext_from_simplecontext.inc Drupal example source code

// $Id: relcontext_from_simplecontext.inc,v 2010/01/29 19:54:02 merlinofchaos Exp $

 * @file
 * Sample relationship plugin.
 * We take a simplecontext, look in it for what we need to make a relcontext, and make it.
 * In the real world, this might be getting a taxonomy id from a node, for example.

 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
$plugin = array(
  'title' => t("Relcontext from simplecontext"),
  'keyword' => 'relcontext',
  'description' => t('Adds a relcontext from existing simplecontext.'),
  'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
  'context' => 'ctools_relcontext_from_simplecontext_context',
  'settings form' => 'ctools_relcontext_from_simplecontext_settings_form',

 * Return a new context based on an existing context.
function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) {
  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data)) {
    return ctools_context_create_empty('relcontext', NULL);

  // You should do error-checking here.

  // Create the new context from some element of the parent context.
  // In this case, we'll pass in the whole context so it can be used to
  // create the relcontext.
  return ctools_context_create('relcontext', $context);

 * Settings form for the relationship.
function ctools_relcontext_from_simplecontext_settings_form($conf) {
  // We won't configure it in this case.
  return array();

Other Drupal examples (source code examples)

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