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'
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) {
// @TODO, we should be able to use this for users too,
// Lets beef this up and make it more intelligent around
// the system path.
if (!isset($_GET['destination'])) {
$_GET['destination'] = $path;
}
// Fetch our callback based on our path.
$page_callback_result = menu_execute_active_handler($path, FALSE);
// Allow other modules to alter the colorbox content.
drupal_alter('colorbox_node_page_callback_result', $page_callback_result);
// If the callback is an integer, we have an error, lets
// render that out as a command.
if (is_int($page_callback_result)) {
$commands = ajax_prepare_response($page_callback_result);
}
else {
$commands = array();
// Is we have an array, lets assume we need to render it out.
if (is_array($page_callback_result)) {
// @TODO: Update this to reflect the correct method once this
// issue is resolved: http://drupal.org/node/1154382
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);
}
}
// Render our commands out to the browser.
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}