Default baseline variables

Last modified: January 6, 2009 - 14:48

The following are the baseline variables available to all template files. They are generated through the preprocessor function, template_preprocess. Variables specific to the template are documented inside the file.

$id
The placement of the template. Each time the template is used, it is incremented by one.
$zebra
Either "odd" or "even". Alternate each time the template is used.
$directory
The theme path relative to the base install. example: "sites/all/themes/myTheme"
$is_admin
Boolean returns TRUE when the visitor is a site administrator.
$is_front
Boolean returns TRUE when viewing the front page of the site.
$logged_in
Boolean returns TRUE when the visitor is a member of the site, logged in and authenticated.
$db_is_active
Boolean returns TRUE when the database is active and running. This is only useful for theming in maintenance mode where the site may run into database problems.
$user
The user object containing data for the current visitor. Some of the data contained here may not be safe. Be sure to pass potentially dangerous strings through check_plain.

Not custom theme hooks?

cwells - April 9, 2009 - 01:41

I'm not seeing any of these baseline variables in my .tpl.php file for a custom theme hook I registered in my theme's template.php using hook_theme. I don't believe they really are available to "all template files," just all "core template files" or perhaps all "core and module template files."

(Or, I'm doing something wrong...)

 
 

Drupal is a registered trademark of Dries Buytaert.