Drupal’s page layout is customarily divided into a number of regions which are laid out
differently from theme to theme. For example, a theme could have regions named Left
sidebar and Right sidebar which will be displayed to the left and right hand side respectively of another region named Content. Regions serve as containers for blocks.
Blocks are self-contained elements which are located within regions and typically contain
information or functionality that is repeated consistently across multiple pages. They can
contain contextual information that complements the actual content of a page such as a block that outputs information about the author of the node currently being displayed, or static information such as a login form block or a block that displays advertisements.
For this example, we will be adding a Recent Comments block to the Left sidebar region, assuming that such a region exists, of the Garland core theme.
How to do it:
- Login to your drupal site.
- Navigate to Admin | Structure | Blocks.You'll see something like below Image.
- Look for the Recent Comments block under the Disabled section.
- Click on the crosshairs icon to its left and drag the block to the Left sidebar region.
- Alternatively, we could have simply chosen the Left sidebar in the Region drop downand then used the crosshairs to order the block within the region. This is the quickeroption when there are a lot of blocks and regions to deal with on this page.
- Click on the Save blocks button at the bottom of the page to save our changes.
- The block should now be visible in the left sidebar as can be seen with the Garland theme in the following screenshot:
How It Works:
- Drupal maintains a table named blocks in its database which contains a list of all the blocks exposed by the modules in its installation. By moving the Who’s online block to the Left sidebar region, we are effectively just manipulating this table in the database. When a page is displayed, Drupal uses this table to determine the status and location of each block for the current theme and the theme system positions them accordingly.
No comments:
Post a Comment