I want to define a region, but the problem is that for different pages, the position of the region would be slightly different. So I can not put the region in page.tpl.php and for different custom modules that I have created, I need to put it inside different places depending on the module. So far I have defined the region inside my custom theme, and I have tested the region inside page.tpl.php with a custom block and it works fine there. But when I put the code to print the region inside the custom module's template, nothing shows up.

The following code works in page.tpl.php but not in custom module's templates:

<?php print render($page['sidebar_ads']); ?>


How do I pass the the $page variable to a custom modules template?

  • To what template exactly you need the region to be passed on?
    – leymannx
    Commented Aug 6, 2019 at 10:13

2 Answers 2


I am not getting exactly. but your position for other pages are different and different for the front page. why not you make two file


You don't need to be worry about region. because region only enable if any block assign in that region!

  • The content of those pages that I'm talking about are so custom, that they don't have anything to do with page--front or nodes or anything else. Thanks for the answer anyways.
    – Milad.N
    Commented Oct 10, 2014 at 12:52
  • @Milad.Nozari – With what do they have to do then? At least an URL or anything unique, no? Then you need to add a custom template suggestion to look for page--myurl.tpl.php or any other custom marker and adjust these templates to print your regions in a different order.
    – leymannx
    Commented Aug 6, 2019 at 10:12

I use the Context module to use areas in different places based on conditions like which content type, view display, or even a specific node id, among other options. So you can specify several regions but instead of using a block in them automatically, allow Context to decide which types of pages will use which block in which region. This should allow for the dynamic display you are looking for in an easy-to-use module interface.

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.