When I am using Drupal through the standard user interface, and click on a node title, Drupal will show the content in the main content area and (depending upon permissions and configuration) will add some tabs between the title and the content. If comments are enabled for the node, a comment entry form will appear below the content field. The tabs and the comment form can be seen in the image below, with the text in red coming from the node fields that resides in the database.
I want to do the same programmatically from the inside of a module. I.e. I want to pull a node from the database, and then display it so that it looks the same as if I've clicked on its title in the user interface.
Here is a more detailed description of what I want to do: I am writing a module to display a node for the user. This module have a button ("Get info") that the user may click. When the user clicks the button, it module pulls various data from a number of external sources, does some processing of this data, and stores the results as a new node object in the database (all this already works).
However, I want to show this node object to the user that pushed the button as soon as it has been created (i.e. to avoid having the user click through a link in order to view it). The user experience I am after his that the user clicks on a "Get info"-button, and then automatically is shown the new node that has been created programatically as a result of this click.
The last bit (showing the user the newly created node) does not work. I am asking for help to get that part of this module right.
So far I've tried to use the following code (suggested here, but later deleted):
$node = node_load($nid); $elements = node_view($node, 'full'); $full = drupal_render($elements);
This results in the follwing display on the page:
Note that there are no tabs ("View", "Edit", etc.) between the title and the content, and no comment form below. The blue "The title" is a hyperlink, i.e. it neccessary for a user to click through that hyperlink to get to a full node view with a comment form.