Closed (fixed)
Project:
Zen
Version:
6.x-2.x-dev
Component:
PHP Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jan 2010 at 03:25 UTC
Updated:
22 Dec 2010 at 03:50 UTC
Hi,
Am I doing something wrong? I can't seem to override region.tpl.php for the sidebar_second region (I haven't added any new regions, just using the base ones).
I've put the following in my template.php:
function <mytheme>_preprocess_region(&$vars, $hook) {
dpm($vars['template_files']);
$vars['template_files'][] = 'silly';
}
However, filenames of region.tpl.php, region-sidebar.tpl.php, region-sidebar-second.tpl.php, silly.tpl.php don't work. This includes putting the files in <mytheme>/ or <mytheme>/templates/....
The dpm() turns up with region-sidebar, region-sidebar-first, and region-sidebar-second.
Thanks!
Comments
Comment #1
mmilo commentedNaming it as
block-sidebar_second.tpl.phpseems to have worked. For anyone else that may need this, don't forget to copy overblock.tpl.phpas well.Oddly enough, if I left it as
region.tpl.phpthe changes showed up on theadmin/build/block/listpage, but not anywhere else. Why is that?Comment #2
johnalbinWhat the…?
Moving this to a bug report until I get a chance to verify this.
Comment #3
jaarong commentedGlad I found this, I'm having the same issue. Trying to create a custom second sidebar region and it will not override using region-sidebar-second.tpl.php. The way I fixed it was moving region.tpl.php and region-sidebar.tpl.php to my sub-theme templates folder. If this is the proper method, it didn't seem that apparent in the docs.
Comment #4
dstotijn commentedI think the discussed issue is:
Template overriding not working if base template doesn't exist in subtheme folder. Not a Zen issue, see: http://drupal.org/node/279573
I'm having a different problem:
Overriding the
zen_preprocess_regionfunction in a subtheme's template.php file doesn't seem to work. Not sure if this is a bug though or if I'm doing something wrong.If anybody has an idea, please elaborate :)
Thanks!
Comment #5
dstotijn commentedPS. I've managed to add my desired candidate function by adding it after line 85 in
template.theme-registry.incin the array of preprocess functions.Comment #6
dstotijn commentedComment #7
johnalbin@dstotijn: Preprocess functions are never "overridden". Your sub-theme can add additional preprocess functions that come after Zen's, but they don't prevent zen's from being run. That's how all preprocess functions.
Also, if you have a different problem, open a different issue.
Comment #8
johnalbinI just committed some code that should make region-REGION-NAME.tpl.php templates work fine in sub-themes.
Please test 6.x-2.x-dev and let me know if it fixes this issue.
Comment #9
jstollerI just updated to the latest 6.x-2.x-dev and my region-REGION-NAME.tpl.php files stopped working.
Comment #10
jstollerIt looks like the code to add region template suggestions was removed from zen/template.php in the last dev update. I added the following to my subtheme's template.php file and it seems to be working.
On a side note, I find it curious that a placeholder theme_preprocess_region() function isn't included in the default template.php file. Was this done intentionally? If so, what is the reasoning?
Comment #11
barrapontoI have just made some tests, and I noticed that adding region-REGION-NAME.tpl.php to the sub-theme templates folder works, but just as any other template file, you must have the base template file in the folder.
Also, from what I read on zen_preprocess_region in template.php:494, the template suggestions are being properly loaded.
Comment #12
johnalbinThe code was converted. Inside
zen_blocks(), region template suggestions are now implemented as "theme hook suggestions" (a pattern in d7 that replaces d6's "template suggestions").