How do I create custom regions in a theme?

Solutions

One other point: Don't miss the required regions!

regions[content] = Content
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom

More on this can be found at http://drupal.org/update/themes/6/7#closure.

To clarify on this point: If you define your own regions, you need to define all that you are using, including those that are required. In other words, you cannot just define additional regions: If you define any, you must define them all.

You define regions in your theme .info file. See: Structure of the .info file

You then need to put the relevant template tags in your page.tpl.php file.

So for example if you defined the region sidebar in your themes .info file, you would then add: <?php print render($page['sidebar']); ?> to the relevant place in your page.tpl.php.

Creating a region for a Drupal 7 theme is not different from creating a region for a Drupal 6 region; the differences between Drupal 7 and the previous versions are essentially:

  • The regions are not defined using a mytheme_regions() function as it was done in Drupal 5, but they are defined in mytheme.info using regions[] directives, which is what is done also with Drupal 6 themes.
  • The regions are rendered using the Drupal function render(), instead of printing the content of a variable.

The default Drupal 7 regions are the following ones:

regions[header] = Header
regions[highlighted] = Highlighted
regions[help] = Help
regions[content] = Content
regions[sidebar_first] = Left sidebar
regions[sidebar_second] = Right sidebar
regions[footer] = Footer

Drupal 7 core themes now include a region named 'highlighted' which uses the same display as the mission statement area in Drupal 6; they also include a region named 'help', that by default has the same content of the $help variable used by Drupal 6.

Tags: Theming / Regions

Similar questions

How to assign blocks to particular regions on theme install?
Drupal 8 provides some blocks by default. Eg. Site Branding, Main Navigation, Powered by Drupal, Search etc. I have created a theme that has Site branding & Main Navigation named regions in which corresponding blocks can be placed. When I enable my theme, Site Branding & Main Navigation blocks are placed in Header & First Sidebar region...
How do i get the all the regions available in the current theme programatically?
I want the list of the names of all regions available in the current theme in drupal 8. How to do this ? And is it possible to get the list of the blocks placed on that region ?
theme Omega 3 - Use of the Regions
you are familiar theme of Omega 3? I have just finished creating a sub-theme and I configured the regions that I need on a page suitable for my content type. I joined two regions, in which I would like the content that I would like to take with php from my content type. But at this point I lies the dilemma. As with the other themes I used a single ...
How to change order and width of two vertical regions in Drupal Bootstrap theme?
There are three vertical regions in Drupal Bootstrap theme: Primary (narrow), Content (wide), Secondary (narrow) I need to move Content region to the left: Content (wide), Primary (narrow), Secondary (narrow) and change width of two regions: make Content region wider (e.g. one column of grid wider) and Primary region – one column narrower , respect...
how to create regions on zen
I would create regions on my zen theme, reflecting the narrow columns side by side. I want a layout that does not provide the content by default, but it plans to create 3 sidebar facing the same width.How can I do? EDIT Also, I want the page layout different from the initial layout of other pages, so I can have different layout templates with diffe...
Create a single template file for the regions in drupal 8
I want to have for example the footer in a single Twig-File. These are my regions: I tried to create a region--footer.html.twig file in the templates folder in my theme, but that doesn't worked. Any suggestions?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.