Exercise 54 Add a Custom Block Region to a Theme

This exercise shows you how to add a custom region to your Bluemarine theme. The region will be added directly above the content area, complementing the block region named content that appears below the content area.

First, if you don't already have a template.php file in your theme, create one. Make sure that it is a true PHP file and starts with <?php.

Next, add this function to the template.php file:

function bluemarine_regions() { return array(

Finally, update the page.tpl.php file with the line of code shown in bold:

<div id="main"> <?php print $content_top; ?>

<?php print $breadcrumb ?> <h1 class="title"><?php print $title ?></h1> <div class="tabs"><?php print $tabs ?></div> <?php print $help ?> <?php print $messages ?>

<?php print $content; ?> <!-- this is the other block region --> </div>

Now when you navigate to administer> blocks (admin/block), you'll be given an additional option for where to place blocks, a shown in Figure 5-6.

Figure 5-6. Adding a block to the Bluemarine theme
0 0

Post a comment