So when creating a Drupal site (for example) it's a very common development helper to print the variables of a form etc. at the top of the page, e.g. using dpm() (assuming the devel module is installed).
I'm having trouble grokking all the ways to do this, and the contexts in which they can be used.
For example, I can use dpm($form) within an implementation of hook_form_alter in my custom module. No problem, the variables are printed nicely at the top of the page.
Now, if I look at a template, say, node.tpl.php I see that there are a load of available variables used to construct the page. So if I pick one, e.g. $links, I would've thought that adding <?php dpm($links); ?> to node.tpl.php would print the variables out for me. But no!
Why is this, what am I doing wrong? :)
dpm() uses drupal_set_message(). At some point in the page rendering process Drupal prints all messages that have been set with this function.
You're using dpm() after that point thus it's too late to add messages to this very page. However you should see them on the next page or after refreshing the current. Not helpful for debugging though.
You may want to give the Theme Developer Module a try.
If you add a new variable to an existing template, to see the changes, you must first flush Drupal cache.
Take a look here to know how to flush Drupal cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With