Drupal print node from nid

Will picture Will · Nov 19, 2010 · Viewed 10.4k times · Source

I have a node id. In my code I want to output this node to the screen using the standard template for the node. How do I print the node to the screen?

Answer

Grayside picture Grayside · Nov 19, 2010

print_r() works fine if you want to just look at the object structure (and using the devel module, the dpm() function that passes that output through krumo is even better).

To view the rendered version of the node, you should call the Drupal API function that is used to take a node object and run all the processing and theming routines used to generate the node output. In that case, it is node_view():

node_view(node_load(###));