Implementing code with custom theme
KillerJerseys - May 22, 2008 - 15:07
| Project: | Block Theme |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hello,
I'm loving the concept of this module, however, I'm lost in the documentation.
I don't see where to add the code
if (module_exists('blocktheme')) {
if ( $custom_theme = blocktheme_get_theme($block) ) {
return _phptemplate_callback($custom_theme,array('block' => $block));
}
}
return phptemplate_block($block);into the template file of my custom ZEN theme. More specifically, I don't see where the [yourtheme]_block($block) is located in the template file. Any help would be appreciated.
Related, does this code need to be modified, or can it be added as-is?

#1
I am having the same problem. I can't tell where to put the code.
#2
just put
function zen_block($block){
if (module_exists('blocktheme')) {
if ( $custom_theme = blocktheme_get_theme($block) ) {
return _phptemplate_callback($custom_theme,array('block' => $block));
}
}
return phptemplate_block($block);
}
#3
I tried using this but it did not work for me. I am working on a zen sub theme. The zen subtheme has this written in the template.php
* theme_block() becomes zen_block()* subtheme_preprocess_block(&$vars) to add variables to the block.tpl.phpWhen i copy the above code my custom blocks disappear. When I select "none" for the block style the blocks reappear.
Any suggestions appreciated.
#4
Hi,
I'm looking into this and from what I found, the issue could be explained if the name(s) you use for your block templates wouldn't be valid php function names. (A dash (-) in the name being a probable suspect). If this is the case, the following code might solve your problem. Notice the extra parameter in the call to _phptemplate_callback():
function zen_block($block) {
if (module_exists('blocktheme')) {
if ( $custom_theme = blocktheme_get_theme($block) ) {
return _phptemplate_callback($custom_theme, array('block' => $block), array($custom_theme));
}
}
return phptemplate_block($block);
}
If it doesn't, please try a blocktheme name with only alphanumerical characters.
Gertjan
#5
All Zen subthemes rely on Zen theme itself so applying the function
function zen_block($block)to Zen's template.php and putting those block templates into Zen root folder does the job.#6
Feasible interim, but we'd like to not mess with Zen root when developing subthemes. This issue might shed some light on the matter -- I too want this module to work with zen subs.
Edit: the hyphens-removal fixed the issue for me
#7
Hi,
I'm having the same problem with a custom sub-theme.
Theme is called 'bluebreeze', but using the fixed width theme inside the bluebreeze folder which I called 'bluesky' (thus my theme).
In template.php the following:
function bluesky_block($block) {if (module_exists('blocktheme')) {
if ( $custom_theme = blocktheme_get_theme($block) ) {
return _phptemplate_callback($custom_theme, array('block' => $block), array($custom_theme));
}
}
return phptemplate_block($block);
}
have created redblock.tpl.php and tried it in the bluebreeze and bluesky folder (and still no difference).
in admin/settings/blocktheme:
redblock|red block
When I change function to bluebreeze_block the blocks go away ..
Please, would most appreciate any help .. and thank you.
Lilian
#8
* bump * sorry ... has someone perhaps found the solution to implementing this on a sub-theme?
#9
Last time I looked (a while ago now...) Zen 5x printed an array of classes via the $block_classes variable.
You should be able to do something like this in the your subthemes proprocess function:
<?php//omit php tags...
function STARTERKIT_preprocess_block(&$vars) {
if (module_exists('blocktheme') && isset($vars['blocktheme'])) {
$block_classes[] = $vars['blocktheme'];
}
}
?>
I just stumbled accross this as I was writing an article on how to implement blocktheme classes per region in the Genesis theme (which is for D6 only) and Zen 5 & 6 work in similar ways using preprocess functions.
#10
Has anyone find out how to get it work in zen subtheme yet?