Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comments
Comment #1
bengt CreditAttribution: bengt commented@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.
Comment #2
Cellar Door CreditAttribution: Cellar Door commentedHow do you want to alter the template? Could this be done via delta/context?
Comment #3
datagroove_ CreditAttribution: datagroove_ commentedAnyone 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?
Comment #4
jowchie CreditAttribution: jowchie commentedsubscribing
Comment #5
RedTop CreditAttribution: RedTop commentedJudging 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
Comment #6
jowchie CreditAttribution: jowchie commentedthis may help... http://eureka.ykyuen.info/2012/05/10/drupal-7-customize-region-template-...
Comment #7
broonI 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 inregion--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 mypreprocess-region.inc
: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.
Comment #8
RedTop CreditAttribution: RedTop commentedstatus changed.
Thx for the info guys! :)
Comment #9
webbykat CreditAttribution: webbykat commentedThat's just what I needed, Paul - thank you for posting it.
Comment #10
mths CreditAttribution: mths commentedWhy are you creating a preprocess-region.inc? 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?
Comment #11
levsoroka CreditAttribution: levsoroka commentedI 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.
Comment #12
broon@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.
Comment #13
Cellar Door CreditAttribution: Cellar Door commented@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.
Comment #14
steinmb CreditAttribution: steinmb as a volunteer commentedComment #15
ilyanice CreditAttribution: ilyanice commentedI had a custom region region--site-nav.tpl.php
I wanted a variable from region.tpl.php (which I define in template.php) to be available in my region--site-nav.tpl.php template. Here's how I did it:
This is where I defined a variable for search box that I will need in my custom region:
And this is how I make a region.tpl.php variable available in region--site-nav.tpl.php