You are here

function colorbox_node_output in Colorbox Node 7

Same name and namespace in other branches
  1. 7.3 colorbox_node.module \colorbox_node_output()
  2. 7.2 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 35
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.
  // Retrieve our node id from the path.
  $nid = array_pop(explode('/', $path));

  // If we have a node, lets display it
  if ($node = node_load($nid)) {

    // @TODO:  If this is a webform, lets modifiy it and add
    // ajax support to keep the webform inside the modal incase
    // of any error messages.
    // We need to fix our destination for contextual links.
    // This prevents a redirect to a screen with no styles.
    $_GET['destination'] = drupal_lookup_path('alias', 'node/' . $node->nid);

    // Render the node to the screen.
    print drupal_render(node_view($node));
  }
  else {
    print '<h2>' . t('Page Not Found.') . '</h2>';
    print t('The following page %path was not found.', array(
      '%path' => $path,
    ));

    // This isn't a node or the node failed to load.
    watchdog('colorbox_node', t('Failed to load a node while attempting to display it through a colorbox.<br />Node ID: ' . $node_id));
  }

  // Do our end of page tasks.  This is very important if using
  // the session for anonymous users.
  drupal_exit();
}