0

I am on D7 using Omega as a base theme. The <h1> tag of my theme can be found in the region--content.tpl.php theme file.

But I want to override this theme in one specific situation: on the user profile pages, I don't want the title to be set on region--content.tpl.php. I will take care of the title on the user-profile.tpl.php theme file. So what I want is a theme file that will override the custom default region theme file in the specific situation where user profiles are being viewed. That theme won't have a title set in it.

I have tried creating specific themes called region--content--user.tpl.php and region--content--user-profile.tpl.php, but they didn't override the default region--content.tpl.php theme. Any ideas? Thank you.

1

I found solution on this blog http://eureka.ykyuen.info/2012/05/10/drupal-7-customize-region-template-file-for-specific-content-type/ and here is my code to suggest a user profile region.

    function YOURTHEME_alpha_preprocess_region(&$vars) {
      $menu_object = menu_get_object();
      if (isset($menu_object->type) && $vars['region'] == 'content') {
        $vars['theme_hook_suggestions'][] = 'region__content__'.$menu_object->type;
        $vars['attributes_array']['class'][] = 'region-content-'.$menu_object->type;
      }
//theme suggestion for user profile
      elseif ($vars['region'] == 'content' && $vars['elements']["system_main"] && $vars['elements']["system_main"]["#entity_type"] == 'user') {
        $vars['theme_hook_suggestions'][] = 'region__content__userprofile';
        $vars['attributes_array']['class'][] = 'region-content-userprofile';
      }
    }

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.