function views_content_context_view_create in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 views_content/plugins/contexts/view.inc \views_content_context_view_create()
1 string reference to 'views_content_context_view_create'
File
- views_content/
plugins/ contexts/ view.inc, line 41 - Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.
Code
function views_content_context_view_create($empty, $data = NULL, $conf = FALSE) {
$context = new ctools_context('view');
$context->plugin = 'view';
if ($empty) {
return $context;
}
if ($conf) {
if (is_array($data) && !empty($data['view'])) {
list($name, $display_id) = explode(':', $data['view'], 2);
$data = views_get_view($name);
if ($data) {
$data
->set_display($display_id);
}
}
}
if (is_object($data)) {
// We don't store the loaded view as we don't want the view object
// cached.
$context->data = array(
'name' => $data->name,
'display' => $data->current_display,
);
// At runtime, this can get populated. Once it is populated this
// object should not be cached.
$context->view = NULL;
$context->title = $data
->get_title();
$context->argument = $data->name . ':' . $data->current_display;
$context->restrictions['base'] = array(
$data->base_table,
);
return $context;
}
}