Custom Drupal Theme Block Regions

How to add/change block regions in a theme?

Add the regions to the xxx.info file, e.g.

regions[header] = Header
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content_top] = Above content
regions[content_bottom] = Below content
regions[footer] = Footer

Modify the page.tpl.php file to match the regions
In this case, the header, left, right, and footer regions are the same as before.
Added the content_top and content_bottom regions
Add them to the page template. e.g.

Before:

        <?php print $breadcrumb ?>
        <h2><?php print $title ?></h2>
        <div><?php print $tabs ?></div>
        <?php if ($show_messages) { print $messages; } ?>
        <?php print $help ?>
        <?php print $content; ?>
        <?php print $feed_icons; ?>
After:
        <?php print $breadcrumb ?>
        <?php print $content_top ?>
        <h2><?php print $title ?><h2>
        <div><?php print $tabs ?></div>
        <?php if ($show_messages) { print $messages; } ?>
        <?php print $help ?>
        <?php print $content; ?>
        <?php print $feed_icons; ?>
        <?php print $content_bottom ?>

The "content_top" and "content_bottom" matches the regions in the .info file.
Now you can ad any blocks you want above the content.

[ref.] http://www.kristen.org/content/custom-drupal-theme-block-regions

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
本篇發表於 themes。將永久鏈結加入書籤。

Custom Drupal Theme Block Regions 有 1 則回應

  1. CNA License 說道:

    This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *