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.

Votre notation : Aucun Moyenne : 2.5 (2 votes)