The Theme System

The Theme System
theme-name_breadcrumb()

theme-engine_ breadcrumb()

theme_ breadcrumb()

Defining Additional Template Files

First, create a file within your theme directory named breadcrumb.tpl.php. This is the new template file for breadcrumbs. Because we wanted to change the <div> tag to a <span> tag, go ahead and populate the file with the following:

<span class="breadcrumb"><?php print $breadcrumb ?></span>

That’s easy enough for a designer to edit. Now you need to let Drupal know to call

this template file when looking to render its breadcrumbs. Inside template.php, override theme_breadcrumb() as you did previously, but this time you’re going to tell this function to use the template file instead of just the function:

function mytheme_breadcrumb($breadcrumb) {

 if (!empty($breadcrumb)) {

       $variables = array(

              'breadcrumb' => implode(' -> ', $breadcrumb)

       );

       return _phptemplate_callback('breadcrumb', $variables);

 }

}

The magic inside this function is happening with _phptemplate_callback(). Its first parameter is the name of the template file to look for, and the second parameter is an array of variables to pass to the template file. You can create and pass along as many variables as you need into your template files.

Defining New Block Regions

function mytheme_regions() {

       return array(

              'left' => t('left sidebar'),

              'right' => t('right sidebar'),

              'content_top' => t('content top'),

              'content_bottom' => t('content bottom'),

              'header' => t('header'),

              'footer' => t('footer')

       );

}

To print out the content top region in your page template, use <?php print $content_top ?>.

你可能感兴趣的:(The Theme System)