You are here

function ctools_term_from_node_context in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 plugins/relationships/term_from_node.inc \ctools_term_from_node_context()

Return a new context based on an existing context.

1 string reference to 'ctools_term_from_node_context'
term_from_node.inc in plugins/relationships/term_from_node.inc
Plugin to provide an relationship handler for term from node.

File

plugins/relationships/term_from_node.inc, line 25
Plugin to provide an relationship handler for term from node.

Code

function ctools_term_from_node_context($context, $conf) {

  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data)) {
    return ctools_context_create_empty('entity:taxonomy_term', NULL);
  }
  if (isset($context->data->taxonomy)) {
    foreach ($context->data->taxonomy as $term) {
      if ($term->vid == $conf['vid']) {
        return ctools_context_create('entity:taxonomy_term', $term);
      }
    }
  }
}