Posted by adshill on January 15, 2009 at 4:56am
| Project: | Insert Block |
| Version: | master |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | firebus |
| Status: | closed (fixed) |
Issue Summary
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
Comments
#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
#8
In patch #5, the following change should be made to account for a module's default title:
Replace:
$block->subject = $title == '<none>' ? '' : check_plain($title);With:
if ($title) {$block->subject = $title == '<none>' ? '' : check_plain($title);
}
#9
subscribing to the thread, any plans for a 1.0 release (not dev)?
#10
subscribing
#11
subscribing, same issue. The patch in # 5 worked.
#12
Here is another patch for menu.inc of core. It fixes bug in title in a another way. It executes SQL query to SELECT block name. It also adds div to wrap content and title.
#13
Subscribing, greetings, Martijn
#14
Patch in #5 works for me. Thanks.
#15
@dealancer -- probably not the greatest idea to hack core :)
#16
Patch in #5 looks good and is in keeping with http://api.drupal.org/api/drupal/developer--theme.php/function/theme_blo....
Patch in #12 doesn't follow coding standards, and may not be needed with #5 in place.
#17
This patch would take care of the symptoms of #489116: Displaying inserted blocks.
#18
Happy with Patch #5
#19
#5 works for me too. zoo
#20
Patch #5 does not work for d7, can someone please re-roll it?
#21
patch #5 worked for me as well
#22
See #8
#23
Thanks JamesK - I didn't get the point of your comment in #8 on first reading.
If there is no title set in block configuration, then the block should be displayed with its default title. The patch in #5 breaks this. And the suggestion in #8 fixes it.
Here's a re-roll of #5 with those changes. I also replaced the db_query with db_query_range, taking the LIMIT statement out of the SQL.
Here is also a patch for D7. The D7 version is very different (and a little simpler), since you cannot invoke theme('block', $block) in D7 the way you could in D6.
#24
Thanks firebus.
#25
Hey, thanks Firebus. That D7 patch (#23) worked for me - I'm also using Block Theme and this now plays nicely with that module too. Happy days.
#26
The patch in #23 worked perfect (D6), thanks.
#27
Fixed.
#28
since people seem to be happy with this patch, i'm moving to RTBC
#29
Thanks everyone for the patches and testing. I've committed the patches in #23 to both the D6 and D7 branches.
If all is quiet for a week or so, after these updates, I'll see about doing some actual releases instead of dev copies.