I'm developing a new custom theme and I need to show a region of the theme only in a specific sections of the site.

I tried looking about how to render a region outside the page template, but I didn't found anything.

Now, if it is possible, how can I do that?

If isn't possible, how can I check if a node is generated by a view from the Views module from the page template? So I could show the region from the correct place when I want to.

I hope my question is clear enough.

Thanks in advance, Mat.

  • 1
    It's not entirely clear what it is you're trying to do. Could you provide more details?
    – jmarkel
    Mar 16, 2012 at 15:27
  • I'm sorry, I'll try to be more specific: I want to show a drupal region outside the page.tpl.php or at least identify if I'm rendering a view from the views module. I want to show a region only if I'm showing a specific view page
    – Matteo
    Mar 16, 2012 at 16:24
  • 1
    Look at the first answer from this question: drupal.stackexchange.com/questions/20054/…
    – ipwa
    May 15, 2012 at 20:23
  • You can create multiple page layouts using Delta modules and use the same for required page. drupal.org/project/delta Sep 20, 2012 at 4:33

2 Answers 2


You might also consider using the Context module to define different contexts for the different cases. But as mentioned elsewhere, the simplest and commonest solution would be to use blocks:

  1. Create a block (or blocks) with the content you wish to show conditionally in it.
  2. Assign that block to the region.
  3. Configure the visibility setting for the block so it only displays on pages with the view on it. An empty region is not displayed on other pages, so if no blocks are visible neither is the region.

If there's a lot of mixed content to be displayed in that region you might also use Panels to create a mini-panel which is then effectively a single block with one visibility setting but having various different items within it (which may also be context-sensitive).

  • Thank you for response, I saw Panels and avoided it, was not the right solution, also, not even using a block was a good solution. I ended up changing totally the approach and avoided needing the region!
    – Matteo
    Mar 21, 2013 at 10:45

The simplest way I can think of to do this would be to put the content you want to show only on some pages into blocks. When you configure the block, set it to display only on the section-specific pages you want to see it on. If the content is in nodes, you can use the NodeBlock module to display them in blocks. Or, if it's dynamic content, you could use Views to create a block that displays the content, configuring the View to show the appropriate content inside the block.

Another way to do this would be to create a second, section-specific, page template. If you add the region to your theme's .info file but then include rendering/display for it only in your special-purpose template, it will only appear on the section-specific pages.

  • So you would use the view to act like a "region" to display some "tagged" blocks?
    – Matteo
    Mar 16, 2012 at 17:05
  • No, not exactly. The view will display inside a Block - which can then be placed in any region you choose. If you're not on a page that the block is allowed to appear on and the region is otherwise empty, it simply won't be displayed at all.
    – jmarkel
    Mar 16, 2012 at 17:55
  • This isn't the solution I need, but, you pointed me in the right direction! Using a page template for the view could maybe allow me to define a region only there, with the appropriate preprocess function in my template.php to have something like page--view.tpl.php
    – Matteo
    Mar 19, 2012 at 8:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.