The Drupal Devel module includes some invaluable functions that make working with Drupal much much easier. A short list of these functions can be found at this post. One of these is the
dpm() command (which I would guess stands for “Drupal Print Message,” or at least that’s how I remember it). Given an array or object, this function will output a div structure at the top of your page that you can use to visually walk through the contents of either of these sets of data. Combine this with existing PHP debugging and instrospection commands and you have a very useful and powerful development tool at your disposal. For example, place this at the top of your Drupal theme’s
<?php dpm( get_defined_vars() ); ?>
Now when you navigate to your page you will have a clickable bar at the top that will list all variables available to the page when it loads, which you can access via the code in your theme page template if you want.
Or maybe you would like to know what path your page took through Drupal’s architecture to its final incarnation, use
dpm() with PHP’s
debug_backtrace() function. This will output an array of each function your page contents went through before they were output to the browser, plus it shows the location of these functions. Try this in place of the code snippet above:
<?php dpm( debug_backtrace() ); ?>