function panels_context_create_node in Panels 6.2
Same name and namespace in other branches
- 5.2 contexts/node.inc \panels_context_create_node()
It's important to remember that $conf is optional here, because contexts are not always created from the UI.
1 string reference to 'panels_context_create_node'
- panels_node_panels_contexts in contexts/
node.inc - @file contexts/node.inc
File
- contexts/
node.inc, line 28 - contexts/node.inc
Code
function panels_context_create_node($empty, $data = NULL, $conf = FALSE) {
$types = array(
'node',
);
// FIXME this is broken when called from panels_page's render process, through panels_context_load_contexts(); it passes in $conf as TRUE.
if (!empty($conf['types'])) {
foreach ($conf['types'] as $type) {
if ($type) {
$types[] = 'node-' . $type;
}
}
}
$context = new panels_context($types);
$context->plugin = 'node';
if ($empty) {
return $context;
}
if ($conf) {
$nid = is_array($data) && isset($data['nid']) ? $data['nid'] : (is_object($data) ? $data->nid : 0);
if (module_exists('translation')) {
if ($translation = module_invoke('translation', 'node_nid', $nid, $GLOBALS['language']->language)) {
$nid = $translation;
$reload = TRUE;
}
}
if (is_array($data) || !empty($reload)) {
$data = node_load($nid);
}
}
if (!empty($data)) {
$context->data = $data;
$context->title = $data->title;
$context->argument = $data->nid;
if (is_array($context->type)) {
$context->type[] = 'node-' . $data->type;
}
else {
$context->type = array(
$context->type,
'node-' . $data->type,
);
}
return $context;
}
}