This module is ridiculously hard to theme. It only prints the default implementation. Even when overriding nodeasblock.tpl.php, AND theme_nodeasblock(), that still only gives you a $content variable and not the whole node array. Plus, it's not rendered correctly.
I found this on line 333 of nodeasblock.module
function nodeasblock_block_content($node) {
$node->build_mode = NODEASBLOCK_BUILD_TEASER;
$node = node_build_content($node, TRUE, FALSE);
$node->body = drupal_render($node->content);
return theme('nodeasblock', $node);
}
You use drupal_render() to create the node content. I would suggest you use node_view() to render the node. This passes it through the theme layer, which - *gasp* - ALLOWS YOU TO USE node-[content_type].tpl.php WHEN THEMING THE BLOCK!!!
In my opinion, this usage is worlds better than drupal_render. It also renders ImageCache presets and sets the 'view' variable in CCK fields.
Changing one line will make all our lives easier:
function nodeasblock_block_content($node) {
$node = node_view($node, $teaser = TRUE, $page = FALSE, $links = FALSE);
return theme('nodeasblock', $node);
}
Comments
Comment #1
earthday47Sorry I meant to post this code at the bottom:
Comment #2
aschiwi commented+1 for this change.
However, this still won't use the imagecache preset set in display fields right?
Comment #3
earthday47I guess you're right. ImageCache must run its hooks after node_view(), I'm not sure.
I got around that by setting the "Maximum resolution for Images" field in the content type to what I wanted, and made sure the ImageAPI JPEG quality was 100% (which I think should be default, but that's neither here nor there).
Comment #4
sachbearbeiter commentedsubscribe