I am stuck with programmatically creating of regions in Drupal 7. I know how to create regions in .info file, but my problem is that I want regions for every node I create, to show a specific block to each and every node differently.

I am interested in Drupal 7 only. If it is possible by creating a module, that is a solution that interests me, too.

  • 1
    Try the Panels Node module (comes with panels). It is better than the solution you are looking for. Sep 13, 2011 at 12:35
  • detail step by step blog: goo.gl/kD3TZu Jul 14, 2015 at 13:13

3 Answers 3

  1. Edit your theme .info file to add the following line:

    regions[youregionname] = Your Region name
  2. Edit your template file (e.g. "page.tpl.php"), and add the following lines:

    <?php if(!empty($page['youregionname'])) : ?> <!--check if region enabled-->
      <div class='my-new-region-class' >   <!--add class to my region-->
        <?php print render($page['youregionname']); ?> <!--print the region-->
    <?php endif; ?>

After editing the files, don't forget to clear the cache.

  • sorry i already mentioned i know how to create region using info file.This is not what i want.
    – pravat231
    Sep 8, 2011 at 19:06

You still need to create your regions in your theme's .info file, as far as I know there's no way around that short of manually adding these new regions to your database. After that get the Node Blocks module which will help you decide which blocks are shown for which nodes, and what regions they are placed in.


As maged adel said, you need to create regions in the .info file and then use these variables in the page.tpl.php file and create blocks from the admin section and then place it on the regions and make it different for different nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.