posts - 431,  comments - 344,  trackbacks - 0
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 ?>.

posted on 2007-12-04 09:29 周锐 阅读(214) 评论(0)  编辑  收藏 所属分类: PHP

只有注册用户登录后才能发表评论。


网站导航: