function views_content_node_from_view_context in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 views_content/plugins/relationships/node_from_view.inc \views_content_node_from_view_context()
Return a new context based on an existing context.
1 string reference to 'views_content_node_from_view_context'
- node_from_view.inc in views_content/
plugins/ relationships/ node_from_view.inc - Plugin to provide an relationship handler for node from view.
File
- views_content/
plugins/ relationships/ node_from_view.inc, line 26 - Plugin to provide an relationship handler for node from view.
Code
function views_content_node_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('node', 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])) {
$nid = $view->result[$row]->{$view->base_field};
if ($nid) {
$node = node_load($nid);
return ctools_context_create('node', $node);
}
}
return ctools_context_create_empty('node', NULL);
}