5

I am using the Menu block module. In one template I have used kpr($page); to see what hooks the menu block is calling. I then created the correct function in my theme's template.php file mytheme_menu_block_wrapper__1(). The examples I have read suggest that this should not take any arguments.

So what I'm really interested in learning is how to debug drupal.

Is there a function that I can call that will show me all the available variables, something like drupal_special_dump() that would show all variables I can use? Any help would be appreciated.

2 Answers 2

8

The Devel module, and it's fantastic dpm() function, is the most widely used debug method for Drupal (at least I'm pretty sure it is).

It can be used on any variable, including arrays and objects, and will post a message to the standard message area containing a nicely structured representation of the variable. It looks something like this:

Devel Output

You would use it as simply as:

function mytheme_menu_block_wrapper__1($vars) {
  dpm($vars);
}

FYI I think all theme functions in Drupal 7 will receive at least one argument which will contain the data for that theme function. That argument is represented by $vars in the above example.

If you're looking to get hold of a list of variables that have been defined for the whole page request you might want to look at the PHP get_defined_vars() function instead.

1

For theme hooks, the variables that are available will be passed to the hook, usually named $variables. :-)

But here's a big list of all the theme hooks: http://api.drupal.org/api/drupal/includes%21theme.inc/function/theme/7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.