Tag Archive: theme

1. Create new menu root for example *merchant*

2. Override function hook_preprocess_page(&$vars) in templete.php and add the following code:

global $user;
if (in_array(‘Merchant’, $user->roles)) {
$vars['nav_links'] = menu_navigation_links(“menu-merchant”);
} elseif (in_array(‘…’, $user->roles)) {

}

3. Add the following code in your tpl file:

<?php print theme(‘links’, $nav_links) ?>

That is all.

1. Adding and manipulating template variables and the Drupal call order:

template_preprocess()
template_preprocess_breadcrumb()
MODULENAME_preprocess() // Defined in module
MODULENAME_preprocess_breadcrumb() // Defined in module
phptemplate_preprocess()
phptemplate_preprocess_breadcrumb()
THEMENAME_preprocess()
THEMENAME_preprocess_breadcrumb()

2. Overriding with Theme Functions and the Drupal call order:

THEMENAME_breadcrumb()
phptemplate_breadcrumb()
sites/all/themes/THEMENAME/breadcrumb.tpl.php
theme_breadcrumb()

3. Devel module and Theme development module is helpful to show you message about theme override.

4. When you theme a CCK filed by adding a file content-filed-field_xxx.tpl.php, do not forget to place an original content-field.tpl.php in the same folder.

5. Do not forget to clear cache if no changes show.

Drupal theme variables

How to use Drupal theme variables?

Add the following codes into themplt.php

&lt;?php
yourthemename_preprocess_page(&amp;$variables) {
$variables['happyday'] = 'Happy ' . format_date(time(), 'custom', 'l') . '!';
}
?&gt;
And display the variables in page.tpl.php:
&lt;?php
print $happyday;
?&gt;