0

I want to override the content region for a specific page, but using the hook page--mypage--region--content.tpl.php won't work. How should I name it?

My site supports block override, I tested this with a dummy region.tpl.php and I currently use a custom page.tpl.php.

  • Why do you want to override the content region for a specific page? Isn't that the same as just having some specific content on a specific page? – David Thomas May 1 '14 at 1:20
  • 1
    @DavidThomas I have done this before on one or two sites where I didn't want to Panel out the entire site, but needed some extra wrappers / inner divs on particular pages to get what the creative director wanted. – mpdonadio May 1 '14 at 1:35
  • I'd be interested to hear more about the requirements from OP, for example additional wrappers could be added in a node template or view template etc.. some more info would help clarify the solution. – David Thomas May 1 '14 at 2:03
  • I want to embed a site-wide contact form in a custom node, with other elements in it, and I didn't want to rewrite the whole page template for the section; I figured the best I could do was override the content region. What do you think? – Severo Raz May 1 '14 at 4:57
  • Sounds like you could just make a webform node page, using the webform module. – David Thomas May 1 '14 at 23:04
0

For this you have to override preprocess region

function MYTHEME_preprocess_region(&$variables) {
    if(CONDITION){
        $variables['theme_hook_suggestions'][] = 'regionspecial__' . $variables['region'];
    }
    print_r($variables['theme_hook_suggestions']); // comment this statement
}

After that your template suggestion name will be 'regionspecial--content.tpl.php' For certain desired condition. Once you clear Drupal's caches your new template file should start being used for that region. It might be worth noting that you'll probably need a copy of the core region.tpl.php file somewhere in your theme folder as well, or the theme registry might not pick up your custom file.

| improve this answer | |
  • What would be a good CONDITION to use? – mpdonadio May 1 '14 at 1:26
  • May be arg(0) is 'test' or whatever – Rupesh May 1 '14 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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