Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I discovered this while working with the Menu Block module. The Menu Block module doesn't show the block titles apparently because the title variable is incorrect.
According to
http://api.drupal.org/api/drupal/modules--block--block.tpl.php/7
The block title should be $block->subject
.
Currently the variable is set to $title
.
I overrode the block.tpl.php template with this one change and Menu Block now shows the block titles properly.
All 4 of the Omega block templates look like they need to be updated.
Here is my change to templates/block/block.tpl.php
<div<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject; ?></h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
<div<?php print $content_attributes; ?>>
<?php print $content; ?>
</div>
</div>
Comment | File | Size | Author |
---|---|---|---|
#8 | ohm_block_title_tpl-2053877-8.patch | 602 bytes | basvredeling |
#3 | omega-block-title-2053877-3.patch | 1.67 KB | jrambeck |
Comments
Comment #1
fubhy CreditAttribution: fubhy commentedDo you want to file a patch for that? Gets you Omega commit credit. Otherwise I can take a look to find out what's wrong.
Comment #2
jrambeck CreditAttribution: jrambeck commentedYou bet.
I've never done that before but I'll figure it out and post it soon.
Comment #3
jrambeck CreditAttribution: jrambeck commentedHere is a patch for the following template files that needed those variable changes:
Simply changing
$title
to$block->subject
as per API docs.Comment #4
fubhy CreditAttribution: fubhy commentedHey, thanks, patch looks good, however, it seems like you did not properly set up your git configuration on drupal.org. I can't properly give you commit credit if you don't do that.
Please go here and configure your d.o account properly:
https://drupal.org/user/185401/edit/git
If you don't want that and just want to be mentioned in the git log then just reply here and I'll do that instead. However, note that that won't give you commit credit and won't list "Omega" as a project you contributed to in your drupal.org profile.
Comment #5
jrambeck CreditAttribution: jrambeck commentedNice. Thanks for the hand holding... I think I got it setup properly now.
Comment #6
fubhy CreditAttribution: fubhy commentedYep, that's correct. Thanks, committed!
Congrats on your first commit.
http://drupalcode.org/project/omega.git/commit/6f2a818
Comment #7
basvredelingThis is still an issue in the Ohm Subtheme.
Comment #8
basvredelingand here's a patch for just #7
Comment #9
Anthony Fok CreditAttribution: Anthony Fok commentedComment #10
fubhy CreditAttribution: fubhy commentedThanks, committed.
Comment #11
marikomay CreditAttribution: marikomay commentedReopening this issue. Block title is still not rendering for me (latest dev version). I tested both Ohm and my sub-theme. No block titles render for either theme.
Comment #12
fubhy CreditAttribution: fubhy commentedComment #13
msmithcti CreditAttribution: msmithcti commentedI've tested this extensively with Omega, Ohm and a newly created sub theme with no issues. I've also ensured we have reverted back to using $block->subject (as core does) throughout. Have you pulled directly from git?
Setting this back to fixed. Feel free to reopen if you can provide some specific steps to reproduce.
Comment #14
marikomay CreditAttribution: marikomay commentedI have retested and discovered that block titles are showing up as expected except for those using Menu Block. The weird thing is that the Menu Blocks are displaying with other themes (Garland, Bartik).
Comment #15
marikomay CreditAttribution: marikomay commentedJust to clarify, I am using the Menu Block module. Also, they do show up when I put the Menu Block in a mini panel using Panels with Omega and when using other themes (Garland, Bartik) with the core block system. I am only seeing this problem when I use Menu Blocks with the core block system and Omega.
Comment #16
marikomay CreditAttribution: marikomay commentedSo it turns out that this issue affects all menu blocks using core block system with Omega. It is not reserved to blocks created with the Menu Block module as I previously posted. I have cleared all cache, disabled, enabled and am using the current dev version of Omega.
Comment #17
msmithcti CreditAttribution: msmithcti commentedI had tested this with core menu block, I will take another look tonight.
Could you also confirm how the title is printed in your Omega block--nav.tpl.php. Is it using , $title or $block->subject?
Comment #18
marikomay CreditAttribution: marikomay commentedThank you for looking into this.
My Omega block--nav.tpl.php is printed $block->subject. Likewise, the title in Ohm block.tpl.php is printed $block->subject. Same issue with both themes.
I am on Mac OS X.
Comment #19
marikomay CreditAttribution: marikomay commentedI figured out the problem I was having. The Ohm block.tpl.php file does include $block->subject, but the Ohm block--nav.tpl.php file doesn't include the title at all. It only prints $content. So that explains the issue when Ohm is enabled.
I'm not sure why my sub-theme didn't inherit Omega block--nav.tpl.php when enabled, but once I copied Omega block--nav.tpl.php to my sub-theme, the title prints successfully. Thank you for your help and for your contribution to this fantastic theme.
Comment #20
fubhy CreditAttribution: fubhy commentedWait... So do you have a ohm subtheme or a direct omega subtheme? Because if you have a direct ohm subtheme and it inherits templates from ohm even though it is not in your base theme trail then there is still a problem. Can you please elaborate on that? Omega subthemes should not inherit ohm templates.
Comment #21
marikomay CreditAttribution: marikomay commentedI am using a direct Omega subtheme (extended version, installed with drush). I was not able to print block titles in a sidebar until I copied Omega block--nav.tpl.php to my subtheme. Since Ohm block--nav.tpl.php prints only $content and not $block->subject (is this intended?), it appears I am inheriting from Ohm?
Comment #22
msmithcti CreditAttribution: msmithcti commentedYes, it does look like that is inheriting from Ohm. What is the location of the Ohm subtheme in your version of Omega? Is it within the subthemes/ directory, or directly in the root of Omega?
Comment #23
fubhy CreditAttribution: fubhy commentedAlso, is there a chance that you have omega installed twice? E.g once via install profile or special site and once via sites/all? Once old and once nee ? We, splatio and me, are both not able to reproduce this. What version of drupal 7 are you using?
Comment #24
marikomay CreditAttribution: marikomay commentedOhm is in the subtheme directory. Strangely, I deleted the templates I had copied from Omega, and the block titles are still printing correctly. I also created new menu blocks and their titles are printing as well. So now it appears I am inheriting from Omega and everything is working as expected. I'm wondering if enabling and setting as default the Ohm theme when testing and then switching back to my direct Omega subtheme created weird caching issues. I did clear cache at every step though.
Comment #25
marikomay CreditAttribution: marikomay commentedI'm on Drupal 7.23 and latest dev version of Omega. I did use a drush make install profile that includes Omega and sets my subtheme as default (subtheme previously created using drush omega-wizard). I don't think I installed Omega twice.
Comment #26
marikomay CreditAttribution: marikomay commentedI did a fresh install using my drush make install profile and all is working. I'll leave the issue open in case you still have questions, but the issue appears to be fixed with the new install.
Comment #27
fubhy CreditAttribution: fubhy commentedSetting back to fixed. Please reopen if someone else is having this issue.
Comment #29
psiegel CreditAttribution: psiegel commentedHello,
I think I have the same problem/ bug but with clean markup. Changing the title hmtl element for the the title is not working with omega.
It seems to come from the block.process.inc process function that has the below line an is overwriting the title variable that is used in clean markup.
$variables['title'] = $variables['block']->subject;
Commenting the line and using the clean markup block template solve the issue. I seems I need to copy overwrite the block template since the omega template is setting the H2 tag. I would prefer not to overwrite the omega block template.
Is the title variable from the process function used anywhere in the various omega script; what do I break when commenting the above line?
Is there any better way to solve this, any suggestion?
Best,
Pascal