Block_term Clarification

Memeshift - May 8, 2008 - 19:01
Project:Block Term
Version:5.x-1.0
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I might be totally missing something here, but what if my template.php does NOT have [yourtheme]_block($block) in it? What do i do then? Should I try page.tpl.php?

#1

Rick Hood - May 12, 2008 - 17:38

You copy that function from here includes/theme.inc (line 882), see: http://api.drupal.org/api/function/theme_block/5

Paste it into your template.php file, change name of function from theme_block($block) to [yourtheme]_block($block), add the code to the end of the file:

if (module_exists('blockterm')) {
if (!blockterm_can_show($block) ) {
return;
}
}

return phptemplate_block($block);

I am in process of trying this module out myself.

#2

iantresman - June 20, 2008 - 21:58
Title:What if your template.php files does NOT have [yourtheme]_block($block) in the code?» Block_term Clarification

So in my aurora template.php file, the function is modified to look as follows (which now has two returns?):

<?php
function aurora_block($block) {
 
$output  = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">\n";
 
$output .= " <h2 class=\"title\">$block->subject</h2>\n";
 
$output .= " <div class=\"content\">$block->content</div>\n";
 
$output .= "</div>\n";
  return
$output;

if (
module_exists('blockterm')) {
    if (!
blockterm_can_show($block) ) {
    return;
    }
}

return
phptemplate_block($block);

}
?>

Or do replace the return $output; line, resulting in:

<?php
function aurora_block($block) {
 
$output  = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">\n";
 
$output .= " <h2 class=\"title\">$block->subject</h2>\n";
 
$output .= " <div class=\"content\">$block->content</div>\n";
 
$output .= "</div>\n";


if (
module_exists('blockterm')) {
    if (!
blockterm_can_show($block) ) {
    return;
    }
}

return
phptemplate_block($block);

}
?>

#3

StuartDH - July 7, 2008 - 09:45

I didn't have the block code in my zen theme but after a bit of trial and error it works for me when I add the following to the bottom of my theme template.php

/**
* add block term
*/
function zen_block($block) {
  $output  = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">\n";
  $output .= " <h2 class=\"title\">$block->subject</h2>\n";
  $output .= " <div class=\"content\">$block->content</div>\n";
  $output .= "</div>\n";

if (module_exists('blockterm')) {
  if (!blockterm_can_show($block) ) {
    return;
  }
}

return phptemplate_block($block);
  return $output;
}

It also seems to work if I remove the penultimate line that contains return $output;

 
 

Drupal is a registered trademark of Dries Buytaert.