You are here

function ctools_context_get_context_from_relationship in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \ctools_context_get_context_from_relationship()

Parameters

$relationship: The configuration of a relationship. It must contain the following data:

  • name: The name of the relationship plugin being used.
  • relationship_settings: The configuration based upon the plugin forms.
  • identifier: The human readable identifier for this relationship, usually defined by the UI.
  • keyword: The keyword used for this relationship for substitutions.

$source_context: The context this relationship is based upon.

$placeholders: If TRUE, placeholders are acceptable.

Return value

A context object if one can be loaded.

2 calls to ctools_context_get_context_from_relationship()
ctools_context_get_context_from_relationships in includes/context.inc
Fetch all active relationships
ctools_context_replace_placeholders in includes/context.inc
Replace placeholders with real contexts using data extracted from a form for the purposes of previews.

File

includes/context.inc, line 874
Contains code related to the ctools system of 'context'.

Code

function ctools_context_get_context_from_relationship($relationship, $source_context, $placeholders = FALSE) {
  ctools_include('plugins');
  if ($function = ctools_plugin_load_function('ctools', 'relationships', $relationship['name'], 'context')) {
    if (!isset($relationship['relationship_settings'])) {
      $relationship['relationship_settings'] = array();
    }
    $context = $function($source_context, $relationship['relationship_settings'], $placeholders);
    if ($context) {
      $context->identifier = $relationship['identifier'];
      $context->page_title = isset($relationship['title']) ? $relationship['title'] : '';
      $context->keyword = $relationship['keyword'];
      if (!empty($context->empty)) {
        $context->placeholder = array(
          'type' => 'relationship',
          'conf' => $relationship,
        );
      }
      return $context;
    }
  }
}