Dissecting Drupal Pages - Continued
Regions
Regions are used to place Drupal “blocks” into a Web site. These
blocks may include site navigation menus, custom views, module
tools, or custom PHP snippets. To see a list of the blocks that
are currently available for your site, navigate to Administer,
Site building, Blocks. Figure 4.7 shows the blocks that are
available for the Hear the North site. This Web site has only a
few modules installed, including a newsletter management tool
Simplenews.
Click here for larger image
Figure 4.7 - Blocks available on the Hear the North Web site.
You can adjust the placement of these blocks by dragging and
dropping the crosshair icon to a new region. To enable disabled
blocks, drag them to a new region. To disable blocks, drag them
back to the “Disabled” section. After updating the placement of
blocks, you must click the button “Save blocks” to commit your
changes to the database. You may also change the order of
several blocks within a region using the same technique.
Adding a new region to your template is a multistep process:
- Edit your theme´s info file and add the regions as
follows:
regions[new_region_name] = Human-readable
region name regions[second_region_name] =
Another region name
- Edit the file page.tpl.php and print your new regions to the
structure of your page. Use the variable names you established
in your theme´s info file.
<?php print
$new_region_name ?>
- Clear the cache to reset the theme registry and enable the
new regions. Navigate to Administer, Site configuration,
Performance. Scroll to the bottom of the Web page and click
Clear cached data.
- You should now be able to place blocks into your new regions
by navigating to Administer, Site building, Blocks.
Here is the basic page template repeated from Chapter 3. A
few changes have been made including the inclusion of new HTML
divisions and one new region (marked in bold) that can be
positioned with CSS. Putting these regions after the main
content of the site will make the content appear more important
to search engines, thereby increasing its rank in search engine
results.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="<?php print $language->language ?>"
xml:lang="<?php print $language->language ?>">
<head>
<title><?php print $head_title; ?></title>
<?php print $head; ?>
<?php print $styles; ?>
<?php print $scripts; ?>
</head>
<body class="<?php print $body_classes ?>">
<div id="main">
<div id="page_title"><?php print $title; ?></div>
<div id="utils-help"><?php print $help; ?></div>
<div id="utils-messages"><?php print $messages; ?></div>
<div id="utils-tab"><?php print $tabs; ?></div>
<div id="main_content"><?php print $content; ?></div>
<div id="utils-rss"><?php print $feed_icons; ?></div>
<div id="new-region-name"><?php print $new-region-name; ?></div>
</div>
<div id="sidebar-left"><?php print $left; ?></div>
<div id="sidebar-right"><?php print $right; ?></div>
<div id="footer"><?php print $region_footer; ?></div>
<?php print $closure; ?>
</body>
</html>
Check back next week where we'll continue this new excerpt from "Front End Drupal: Designing, Theming, Scripting" from Prentice Hall.
Theming Menus
Drupal Front End
Blocks
|