Use theme_block() to render blocks
adshill - January 15, 2009 - 04:56
| Project: | Insert Block |
| Version: | HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
I really like this - always been a bit fan of insert view, but this is a great addition. My problem is that the block is coming out with the title on it and it is the title created by the module. Is there any way to either remove the title all together or to use the title overide in the block settings instead?
Thanks,
Adam

#1
Hi,
I confirm this issue and subscribe for a solution. This module don't care about the block setting for the title. Result, it shouldn't show the title when it is set as into the block configuration.
#2
The problem is that insert_block module uses its own theming function, which is unnecessary (and wrong, as it does not check the title)
line 82
$repl[] = theme('insert_block_block', $block);should be changed to
$repl[] = theme('block', $block);and all the theme related code can be removed..
#3
actually this does not help as the block setting is not loaded, so the code does not know about if the block title is set to
<none>or not.But changing to core theme_block function, enables the use of new template files
function template_preprocess_block(&$variables) {...
$variables['template_files'][] = 'block-'. $variables['block']->region;
$variables['template_files'][] = 'block-'. $variables['block']->module;
$variables['template_files'][] = 'block-'. $variables['block']->module .'-'. $variables['block']->delta;
so you can use the template by region, where you can remove the title
block-insert_block.tpl.php (based on block.tpl.php)
<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="block block-<?php print $block->module ?>"><div class="content">
<?php print $block->content ?>
</div>
</div>
attached the patch, and the patched module file..
#4
#5
Thanks Pasqualle for the code, it was just what I was looking for. Unfortunately, the patch provided in comment #3 didn't work for me, so I've included a new one, rolled against HEAD.
I've also added a database call which fetches the block title, and then erases it if it is set to
<none>.#6
instead of additional db query I would prefer an additional parameter, to show or hide the title. In most cases you want to hide the block title if you put it into a template or node, but you want to show the block title if you put that block into a region.. So those should be 2 different settings..
like
[block:module=delta=hide_title][block:profile=0=TRUE]
This way the functionality of insert_view and insert_block would be the same as in the quicktabs module..
#7
Great Code But what I really need is a way to show one part of a menu (block) expanded!
Any thoughts on this?
Regards
Ron