You are here

function nodereference_node_from_noderef_context in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 modules/nodereference/panels/relationships/node_from_noderef.inc \nodereference_node_from_noderef_context()
  2. 6.2 modules/nodereference/panels/relationships/node_from_noderef.inc \nodereference_node_from_noderef_context()

Return a new panels context based on an existing context

1 string reference to 'nodereference_node_from_noderef_context'
nodereference_panels_relationships in ./nodereference.module
Implementation of hook_panels_relationships().

File

./nodereference.module, line 568
Defines a field type for referencing one node from another.

Code

function nodereference_node_from_noderef_context($context = NULL, $conf) {

  // If unset it wants a generic, unfilled context, which is just NULL
  if (empty($context->data)) {
    return panels_context_create_empty('node', NULL);
  }
  if (isset($context->data->{$conf['field_name']}[0]['nid']) && ($nid = $context->data->{$conf['field_name']}[0]['nid'])) {
    if ($node = node_load($nid)) {
      return panels_context_create('node', $node);
    }
  }
}