Content rendering/theming in Omega seems to be done via the region--content.tpl.php file. I would like to override this file for one content type only (much like node-contenttype.tpl.php). Can this be done?


bengt’s picture

@RedTop: Have you got any answer for this question? I thought that I maybe could use THEMENAME_preprocess_region(&$variables) together with $variables['theme_hook_suggestions'] but I have not been successful.

Cellar Door’s picture

How do you want to alter the template? Could this be done via delta/context?

datagroove_’s picture

Anyone figure this one out yet? I too need to change the region--content.tpl.php file for one content type, what is the template suggestion we should use?

jowchie’s picture


RedTop’s picture

Category: support » bug
Priority: Normal » Major

Judging by the replies it doesn't look like this can be done. Changing category and priority to attract Himerus' attention. Maybe he knows how to do this.

reason for status
seems to break standard, major Drupal theming functionality (being able to override / change how $content is presented per content type )

bug description
In other themes node.tpl.php contains $content. Drupal theming provides a way to override this template per content type using the node-'contenttype'.tpl.php naming convention. In Omega $content is part of the region template files for which Drupal does not seem to offer a similar override.

This is some pretty important shit, y'know. :P

jowchie’s picture

Paul Broon’s picture

I was just in the need of that and came up with a similar solution as stated in #6. (Thanks jowchie! Your way is actually smoother since it doesn't drag the node variable along.)

I have some special content types which require different layouts including the node title. For theming the content, I am already using node--mycontenttype.tpl.php, but node title is set in region--content.tpl.php. Though, $node is not available in that file.
I tried to make $node available by adding it via preprocess function and after reading the link stated above, I merged both ways and added this function to my

function MYTHEME_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;

Now, I can use special template files for each content type by creating custom region--content--CONTENT_TYPE1.tpl.php, region--content--CONTENT_TYPE2.tpl.php and so on.
Further, I added another class (see last line of code) to style the region itself if necessary.

Don't forget to clear cache after adding the preprocess function and the template file.

RedTop’s picture

Category: bug » support
Priority: Major » Normal
Status: Active » Needs review

status changed.

Thx for the info guys! :)

webbykat’s picture

That's just what I needed, Paul - thank you for posting it.

mths’s picture

Why are you creating a It doesn't work for me and it only worked until I just put the function in my template.php. Isn't that the usual way to go?

levsoroka’s picture

I put this inside template php and this does not work for me, array for hook suggestions is not being appended with new item, nor atributes.

Paul Broon’s picture

@mths: Sorry for confusion. You are right, the default way is to put it into template.php. In that case however, I was using an Omega subtheme (it's an Omega issue after all) and it separates the various process and preprocess functions into different folders and files. For most of my projects this is quite handy as it helps to have custom code snippets organized.

Cellar Door’s picture

@mths: If you are using a preprocess function in the template.php be sure you format it MYTHEME_alpha_preprocess_hook(&$vars){} like the example. Preprocess functions can go into the template.php but like Paul.B stated they can also go into custom .inc files in the preprocess folder. Both should work for you though.

steinmb’s picture

Issue summary: View changes
Status: Needs review » Closed (fixed)