One reason for me to use nodeblock module is that it allows html in the block title - unlike the native Drupal blocks, which escape the title. Typically, I want to add some span tags to give some elements in the block title a different font size or color.

The downside is that now the escaped html tags appear in node and block listings, and in the edit page itself.

A nice solution would be to use a CCK field as the block title.

A simple and flexible way to do that with nodeblock would be to give the $node variable to the block template, so it can be used in theme preprocess functions for block.tpl.php.

In nodeblock.module:

<?php
function nodeblock_block($op = 'list', $delta = 0, $edit = array()) {
  [..]
  
    $block['subject'] = $node->title;
    // using page arg = TRUE since we want the full content (generally speaking)
    $block['content'] = node_view($node, FALSE, TRUE, TRUE);
    
    $block['nodeblock_node'] = $node;
    
    return $block;
  }
}
?>

Another solution would be to make a function theme_nodeblock_subject($node) that would by default use the node title as the subject.

Comments

donquixote’s picture

I found a very easy solution that requires a minimal patch.

In nodeblock.module, starting with line 121 (function nodeblock_block).

Old code:

<?php
    $block['subject'] = $node->title;
    // using page arg = TRUE since we want the full content (generally speaking)
    $block['content'] = node_view($node, FALSE, TRUE, TRUE);
?>

New code:

<?php
    // using page arg = TRUE since we want the full content (generally speaking)
    $block['content'] = node_view($node, FALSE, TRUE, TRUE);
    $block['subject'] = $node->title;
?>

Now you can manipulate $node->title in your template or theme function, using the cck fields of your choice.
It's a bit odd, yes, but it works!

donquixote’s picture

I think the following is more useful:

<?php
    $block['subject'] = $node->title;
    // using page arg = TRUE since we want the full content (generally speaking)
    $block['content'] = node_view($node, FALSE, TRUE, TRUE);
    // let the block template know about the node data
    $block['nodeblock_node'] = $node;
?>
tom_o_t’s picture

Johnny vd Laar’s picture

Status: Active » Fixed

I've added an improvement in the Drupal 7 version. I won't include this in Drupal 6:
http://drupalcode.org/project/nodeblock.git/commit/5afcb66

donquixote’s picture

Hi,
The use case I had when I opened is now long ago, I don't even remember it - so I can't give much feedback atm.
I still want to say thank you for picking it up :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.