Skip to main content

You are here

Block to show node data structure

One of the most frustrating tasks for a new Drupal developer is to visualize the information structures produced by Drupal during a page load. This can be extremely importand during major version upgrades, when intrinsic changes to data structures can break the php code your previous site relied on.

Rather than hacking modules, writing print_r outputs to watchdog, or other methods I have heard of, I generally create a php enabled block, restricted to the administrator role, and activate it in the page footer.

The code to display the $node object structure in D7 is:

$node = menu_get_object();
print "node " . $node->nid . " array is: <pre>" . print_r($node, TRUE) ."</pre>";

Showing the block only for the administrator role even allows you to activate it on a live site that you are trying to trouble shoot.

Link to this page

To refer others to this page copy the following link code and paste it into your page, blog, text or email.

Premium Drupal Themes by Adaptivethemes