Add a custom region to a Drupal theme

You've certainly wanted to add a bock region to a theme. No problem, this tutorial is made for you. In this tutorial, you will learn how to add easily in 4 steps how to add a region to your theme.

Let's start:

 

1. Open the .info file of your theme located in the theme folder.

2. Add this line to that file:

           regions[mycustomregion] = mycustomregion

    (you can choose a different name).

3. Open the file page.tpl.php and add this code where you want your custom region to appear:

                 <?php if ($mycustomregion): ?>

                       <div><?php print $mycustomregion ?></div>

                 <?php endif; ?>

You can apply a class to this div.

4. Go to the themes page in your browser, select the customized theme if it's not already done then click the save button.

 

That's all! Hope you liked.

No votes yet

Comments

Great post, I\'ll be back for

Great post, I\'ll be back for more ;)

This will not work for me for

This will not work for me for bluemarine theme. As I want to add one custom region with existing theme

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 15 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.