Monday, June 28, 2010

How to register a variable for used in page.tpl.php?

How to register a variable for used in page.tpl.php?

<?php
function YourModuleName_preprocess(&$vars, $hook) {
  if ($hook == 'page') {
    $vars['hello_world'] = 'Hello World';
  }
}
?>

add following line to sites/all/themes/your_theme/page.tpl.php
<?php print $hello; ?>

Reference: http://drupal.org/node/223430

No comments: