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
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

duckjerk - May 31, 2008 - 20:05

I am having the same problem. I can't tell where to put the code.

#2

FlymastaFlex - June 2, 2008 - 15:21

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);



}
into your template.php

#3

DonCoryon - June 29, 2008 - 00:30

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.php

When i copy the above code my custom blocks disappear. When I select "none" for the block style the blocks reappear.

Any suggestions appreciated.

#4

g.idema - July 3, 2008 - 19:31

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

Miteto - July 30, 2008 - 09:53

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

lefnire - August 30, 2008 - 07:07

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

Liliplanet - November 4, 2008 - 15:26
Title:Implementing code with custom ZEN theme» Implementing code with custom theme

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

Liliplanet - November 9, 2008 - 08:04

* bump * sorry ... has someone perhaps found the solution to implementing this on a sub-theme?

#9

Jeff Burnz - February 6, 2009 - 15:53

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

ckjian - May 29, 2009 - 10:17

Has anyone find out how to get it work in zen subtheme yet?

 
 

Drupal is a registered trademark of Dries Buytaert.