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>
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fubhy’s picture

Do 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.

jrambeck’s picture

You bet.

I've never done that before but I'll figure it out and post it soon.

jrambeck’s picture

Version: 7.x-4.0-beta6 » 7.x-4.x-dev
Status: Active » Needs review
FileSize
1.67 KB

Here is a patch for the following template files that needed those variable changes:

Simply changing $title to $block->subject as per API docs.

block--minimal.tpl.php
block--nav.tpl.php
block.tpl.php
fubhy’s picture

Hey, 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.

jrambeck’s picture

Nice. Thanks for the hand holding... I think I got it setup properly now.

fubhy’s picture

Status: Needs review » Fixed

Yep, that's correct. Thanks, committed!

Congrats on your first commit.

http://drupalcode.org/project/omega.git/commit/6f2a818

basvredeling’s picture

Status: Fixed » Needs work

This is still an issue in the Ohm Subtheme.

basvredeling’s picture

and here's a patch for just #7

Anthony Fok’s picture

Status: Needs work » Needs review
fubhy’s picture

Status: Needs review » Fixed

Thanks, committed.

marikomay’s picture

Status: Fixed » Active

Reopening 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.

fubhy’s picture

Assigned: Unassigned » msmithcti
msmithcti’s picture

Status: Active » Fixed

I'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.

marikomay’s picture

Status: Fixed » Active

I 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).

marikomay’s picture

Just 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.

marikomay’s picture

So 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.

msmithcti’s picture

I 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?

marikomay’s picture

Thank 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.

marikomay’s picture

Status: Active » Fixed

I 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.

fubhy’s picture

Status: Fixed » Active

Wait... 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.

marikomay’s picture

I 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?

msmithcti’s picture

Yes, 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?

fubhy’s picture

Also, 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?

marikomay’s picture

Ohm 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.

marikomay’s picture

I'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.

marikomay’s picture

I 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.

fubhy’s picture

Status: Active » Fixed

Setting back to fixed. Please reopen if someone else is having this issue.

Status: Fixed » Closed (fixed)

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

psiegel’s picture

Issue summary: View changes

Hello,

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