Drupal 7: How to check the available variables in a template (tpl) file

There is a very handy php function that allows us to quickly check all the available variables in a tpl file (e.g. html.tpl.php).
Assuming that the devel module is installed, the following line should do the trick:

<?php kpr(get_defined_vars()); ?>

Alternatively, a print_r should work just fine:

<?php print_r(get_defined_vars()); ?>

More info: http://php.net/manual/en/function.get-defined-vars.php

Drupal 7, Drupal Quick Tips

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x