function colorbox_node_output in Colorbox Node 7.2
Same name and namespace in other branches
- 7.3 colorbox_node.module \colorbox_node_output()
- 7 colorbox_node.module \colorbox_node_output()
1 string reference to 'colorbox_node_output'
- colorbox_node_menu in ./colorbox_node.module
File
- ./colorbox_node.module, line 39
- Creates a menu callback with support for displaying a node inside of
a colorbox.
Code
function colorbox_node_output($path) {
if (!isset($_GET['destination'])) {
$_GET['destination'] = $path;
}
$page_callback_result = menu_execute_active_handler($path, FALSE);
drupal_alter('colorbox_node_page_callback_result', $page_callback_result);
if (is_int($page_callback_result)) {
$commands = ajax_prepare_response($page_callback_result);
}
else {
$commands = array();
if (is_array($page_callback_result)) {
if (isset($page_callback_result['nodes'])) {
foreach ($page_callback_result['nodes'] as $nid => $tmpNode) {
if (isset($tmpNode['#view_mode'])) {
$node_view = $tmpNode['#node'];
$node_view_array = node_view($node_view, 'colorbox');
if (module_exists('comment')) {
$node_view_array['comments'] = comment_node_page_additions($node_view);
}
$rendered_node = drupal_render($node_view_array);
$page_callback_result['nodes'][$nid] = array(
'#markup' => $rendered_node,
);
}
}
}
$html = drupal_render($page_callback_result);
$commands[] = ajax_command_html('#cboxLoadedContent', $html);
}
else {
$commands[] = ajax_command_html('#cboxLoadedContent', $page_callback_result);
}
}
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}