function views_content_term_from_view_context
Return a new context based on an existing context.
1 string reference to 'views_content_term_from_view_context'
- term_from_view.inc in views_content/
plugins/ relationships/ term_from_view.inc - Plugin to provide an relationship handler for term from view.
File
-
views_content/
plugins/ relationships/ term_from_view.inc, line 26
Code
function views_content_term_from_view_context($context, $conf, $placeholder = FALSE) {
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || $placeholder) {
return ctools_context_create_empty('entity:taxonomy_term', NULL);
}
$view = views_content_context_get_view($context);
// Ensure the view executes, but we don't need its output.
views_content_context_get_output($context);
$row = intval($conf['row']) - 1;
if (isset($view->result[$row])) {
$tid = $view->result[$row]->{$view->base_field};
if ($tid) {
$term = taxonomy_term_load($tid);
return ctools_context_create('entity:taxonomy_term', $term);
}
}
return ctools_context_create_empty('entity:taxonomy_term', NULL);
}