How to use Drupal theme variables?
Add the following codes into themplt.php
<?php
yourthemename_preprocess_page(&$variables) {
$variables['happyday'] = 'Happy ' . format_date(time(), 'custom', 'l') . '!';
}
?><?php
print $happyday;
?>Complex themes have many different block regions, some regions will only appear on certain pages or when viewing nodes of certain types. One very common use-case is
to have both a page.tpl.php, and a page-front.tpl.php, each of which print out different regions.
How to define block regions in Drupal? Simply add a couple lines in your theme’s .info file:
regions[ad_top] = Ad Top
regions[ad_bottom] = Ad Bottom
regions[front_sidebar] = Front Sidebar
regions[sidebar_ad] = Sidebar Ad
regions[content] = Content
regions[feature_a] = Feature A
regions[feature_b] = Feature B
regions[feature_c] = Feature C
regions[feature_d] = Feature D
And then in your *.tpl.php file, wherever you want the region to appear, simply print out its machine-readable name.
<?php
print $feature_a;
?><front> page.