Hi everyone - first post. Very new to drupal, starting out with Drupal 7. I've gotten an intro to theming and template suggestions here: http://pingv.com/blog/a-peek-at-drupal-7-theme-system-changes but I've run into problems attempting to create a template override for the content region. I want to override the region.tpl.php file, but only for a specific content type.
I have a content type "Client" that has a page view that displays html in the content region. Now, I can copy the core region.tpl.php file into my theme folder and rename it region--content.tpl.php, but that would override the region template for everything under the content region. I would like to restrict it to just the Client content type. I've tried region--content--client.tpl.php, but that doesn't work. I've also tried naming the file by path, like: region--content--client-detail.tpl.php (since I was able to override html.tpl.php and page.tpl.php by naming them with the path). Neither of those suggestions seems to work.
Is there a naming convention for the region template file, or will I have to learn about preprocess?
Comments
Just a thought
Why are you theming a region for one content-type? Seems like you could add a region to your .info file and then add the following to your template.php file to create content-type specific page template files.
function THEMENAME_preprocess_page(&$variables) {if (isset($variables['node']->type)) {
$nodetype = $variables['node']->type;
$variables['theme_hook_suggestions'][] = 'page__' . $nodetype;
}
}
also, to answer your question ... yes, do learn about processing and preprocessing. :-)
Thanks. I didn't realize you
Thanks. I didn't realize you could specify the theme suggestions like that. I'll have to dive into the processing/preprocessing stream for sure.
This all came about because I have a view that I need to theme two different ways. The first is straight HTML output for desktop/mobile users. That's straightforward enough. The second is XML output to support a legacy frontend done in Flash. I originally tried the Feed output for my view, but that didn't allow me to specify the field output. So I figured I'd just override the html/page/region/field output. The html and page templates were easy to override for the specific path to my view page, and so were the individual fields. Unfortunately the region template was still wrapping html tags around the fields, so I had the html/page template xml tags, and the field xml tags, with the default region html sandwiched in between. It's difficult because I not only have to theme differently by content type, it's the content type in a specific view context (xml output).
I've managed to override a bunch of the different templates and I'm getting the output I need, but I have a feeling there's got to be a better way to do this.
Been there ...
If you need help with the XML part, contact me dirrectly. I did that for www.pennzoil.com and www.serta.com.