Analyzing variables using the Devel module
While working with the Drupal API, we will often be faced with the situation where we have no idea how a variable is structured. While PHP provides a number of functions to peek into the variable, Drupal's Devel module provides a cleaner solution and a prettier interface to do the same.
In this recipe, we will be looking at the Devel module's dpm()
function.
Getting ready
It is assumed that the Devel module has been installed and is enabled. It also comes with its own set of permissions and it is assumed that the current user has all the appropriate permissions including access devel information.
We will also be making use of the mysite module created earlier in this book to hold our odds and ends.
How to do it...
The following steps are to be performed inside the mysite module folder at sites/all/modules/mysite:
Open the file
mysite.module
in an editor.Look for an implementation of the
mysite_init()
hook. If it is unavailable, create one and add the...