function ctools_terms_from_node_context in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 plugins/relationships/terms_from_node.inc \ctools_terms_from_node_context()
Return a new context based on an existing context.
1 string reference to 'ctools_terms_from_node_context'
- terms_from_node.inc in plugins/
relationships/ terms_from_node.inc - Plugin to provide an relationship handler for all terms from node.
File
- plugins/
relationships/ terms_from_node.inc, line 26 - Plugin to provide an relationship handler for all terms from node.
Code
function ctools_terms_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('terms', NULL);
}
// Collect all terms for the chosen vocabulary and concatenate them.
if (isset($context->data->taxonomy)) {
$terms = array();
foreach ($context->data->taxonomy as $term) {
if (in_array($term->vid, $conf['vid'])) {
$terms[] = $term->tid;
}
}
if (!empty($terms)) {
$all_terms = ctools_break_phrase(implode($conf['concatenator'], $terms));
return ctools_context_create('terms', $all_terms);
}
}
}