Although it is possible to define blocks as appearing in the header area (along with content, footer, left sidebar and right sidebar), when this is done, they appear nowhere and, looking at the code, the region does not actually exist.

This prevents use of this area for emergency messages appearing above content, which is a common use of the header area.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm’s picture

Title: Header area missing » Header region missing
Status: Active » Needs review
FileSize
1020 bytes

I've provided a quick fix (ok, call it a hack) : since the appropriate region for the "header" region is the same as the mission, this patch just implements the "header" region as another instance of the mission div.

I *know* it's not as should be, but until a better garland specialist gives the proper fix, this allows users with garland deployed to have a "header" region in the proper place... and I needed it !

moshe weitzman’s picture

Priority: Normal » Critical

our default theme can't ship without supporting our default regions.

ontwerpwerk’s picture

The quick fix is actually a reasonable idea for the place of the header, but the blocks in the header will be totally mangled.
I think there should be a lot more prepared styles to handle the layout for blocks in the header.

fgm’s picture

FWIW, you can see how it looks with that fix on http://www.php-gtk.eu

Steven’s picture

The fact that templates can't define their own regions (or features) for that matter is a flaw in the theme system. There is simply no room in the design for header blocks, nor any appropriate styling for them.

Note: the ability to use "themename_regions()" is unacceptable as it breaks the principle that templates should be freely copyable from one directory to another.

Won'tfix as far as I'm concerned. The suggested patch is broken as it duplicates the element with id "mission".

cog.rusty’s picture

It's not so bad. I'd keep the header blocks region and ditch the mission. If they can't tell what my mission is...

chx’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
455 bytes

[18:02] <chx> noone has any good idea about that header region problem?
[18:03] <UnConeD_> chx: abolish the header region :P
[18:03] <UnConeD_> i've never seen a theme that actaully uses it in a usable fashion
[18:03] <chx> UnConeD_: fine with me
[18:03] <m3avrck_> thumbs up from me
[18:04] * RobRoy has used the header region
[18:05] <RobRoy> but it took lots of CSS to make it look right, I guess by default we could scrap it
[18:05] <RobRoy> since it's rarely used and since it requires lots of work to make it look nice, only people who know how to add a new region in template.php will do so

cog.rusty’s picture

Hmm... abolish from phptemplate.engine because Garland is not designed for this?
Isn't there a place for a less drastic abolishment?

Dries’s picture

I too, have yet to see a site take advantage of this. I'd be OK with removing it.

cog.rusty’s picture

Yes, but you know what the problem is? It is true that hardly any theme has been using it but on the other hand we don't have many killer themes currently. The question is who is going to develop those missing killer themes. RobRoy's last argument was a bit hasty in that he assumes that php programmers will do it.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
547 bytes

i don't like where this is going. removing this region is just causing hassles for uprgaders with little benefit. "i haven't seen many sites use this" isn't a very compelling argument. none of us sees the backend of many drupal sites. consultants probably see the most, and i have seen several use the header region. perhaps big/costly sites are more likely to take the time to use regions, instead of just hacking page.tpl.php as desired.

adds a header region above content and uses region-header as the name of the id, since header is already used

cog.rusty’s picture

FileSize
756 bytes

One more patch, just to be thorough.
Garland and Minelli use the regions which they... use.

A benefit is that Garland is the only core theme using a template.php and a demonstration of this feature wouldn't harm.

webchick’s picture

Definitely -1 for removing the header region from core altogether, especially this late in the release cycle. That is not a fix.

+1 for either moshe's patch in #11 (preferred; needs the indenting fixed though) or CogRusty's patch in #12.

chx’s picture

FileSize
2.18 KB

The fact that templates can't define their own regions (or features) for that matter is a flaw in the theme system.

The Drupal Way is then to fix this flaw. We already have the necessary mechanism in place we just need to use it: _phptemplate_variables to the rescue.

With this we still have a default phptemplate_regions for themes that do not have a template.php . And, by using _phptemplate_variable for Garland's template.php , Minelli and other derivatives is fixed too. The code change is minimal, I just factored out the variables call to its own function with Doxygen of course.

chx’s picture

FileSize
3.53 KB

I upped the wrong file.

Dries’s picture

I don't really like the way this works. It introduces yet another mechanism to overwrite defaults. Better to standardize on one system, rather than to invent a dozen parallel, yet slightly different systems. That is, use (regular) hooks. Either the theme implements a regions hook, or the default regions hook is used. This theme stuff is getting crufty.

(Moshe: I've seen a fair amount of Drupal sites in my life despite the fact that I'm not a consultant. The theory that only consultants gets exposed to certain functionality is ... weird. The people that commented on this issue spent time with more than one Drupal site and have more experience theming Drupal sites than you and me together.)

webchick’s picture

The people that commented on this issue spent time with more than one Drupal site and have more experience theming Drupal sites than you and me together.

This is true; however, the change that most of said people supported (removing the header region from core altogether) doesn't affect advanced themers; advanced themers will probably override this anyway, and have several regions in their themes: header-nav-left, header-nav-right, or whatever.

This change would affect Mr. Joe Blow who just runs a pretty straight-forward 4.7 site with one of either the core or contributed themes with possibly some minor colour changes or whatever. He throws a block with some banner code in the "header" region. It might not look that great, but it's functional and does what he needs it to do.

But now, when he upgrades to 5.0, the banner is gone. He goes to admin >> blocks and the "header" region is gone. He's now officially stuck without diving into template.php in order to put it back. This is not a solution.

(It's worth pointing out that most of us have probably never seen or worked sites like this, because the people who build sites like this don't have the money to hire us to look at it. ;) They're little hobby sites or non-profit sites, etc.)

I don't know for sure if chx's method is "the" solution either, but it has the following advantages:

  • Doesn't strip out the "header" region from all of core just because it's difficult to theme in Garland.
  • Doesn't break any existing themes implementing a theme_name_regions() function.
  • Provides a mechanism that can apply to any PHPTemplate theme regardless of what it's called by way of the _phptemplate_variables function. So newbie themers can just copy/paste the Garland theme into "Garland2" and start hacking it with no loss of functionality and without having to go into template.php and rename "garland_regions" to "garland2_regions".
chx’s picture

It introduces yet another mechanism to overwrite defaults

I do not do anything like that. _phptemplate_variables was there, I reused it actually.

Egon Bianchet’s picture

My 2 cents:
The header and footer regions have always been rather broken in all themes I remember, and I suspect that header region is often used to place a block before the content, since there is no default "before content".

So if header is so difficult to theme, I propose to remove that region from the theme and put a "before content" region instead (or "top of the page", etc), like moshe's patch at #11.

fgm’s picture

FileSize
1.95 KB

+1 on Moshe's solution, which is minimal and preserves the highest level of compatibility. Attached is an enhanced version with two added styles for #header-region. This is the one currently online on the site I already mentioned.

It more detail, I think Webchick really nailed it. Most of the others in this thread seem to ignore the very simple use case I pointed out when entering this issue: the need for non-specialists to have a trivial-to-use feature allowing a site admin to have some content display on his site for an urgent situation (and remove it with just one click when the emergency subsides), without having to resort to patching a theme.

Of course, any of us can create a theme with that feature, but I suspect not many, myself included, would probably be able to create something as nice-looking as garland).

So, for most sites except the larger ones built by a drupal professional and using stock/contrib themes, using a patched theme just for a basic feature like this means in manys case they will not take advantage of new versions and patches because it would require reimplementing their changes. So I think the other solutions offered, although technically sound, are reducing drupal's overall value for simple sites.

Hence the +1.

ontwerpwerk’s picture

The reason nobody uses the header for blocks is that blocks there look out of place: imagine a login block in the header, it won't fit, same goes for almost any other block. The only blocks that will look good there are custom blocks which span the whole width of the region and not even have a title.

So the only reason to add a header block there is backwards compatibility - which is a good reason. But please don't do it without making the blocks looking at least reasonable in that region.

fgm’s picture

Title: Header region missing » zzzHeader region missing

Ontwerperk, do you mean you find the example I suggest (www.php-gtk.eu) not appropriate ?

sime’s picture

Title: zzzHeader region missing » Header region missing

So the only reason to add a header block there is backwards compatibility - which is a good reason. But please don't do it without making the blocks looking at least reasonable in that region.

I disagree. I would like backwards compatibility even if the blocks won't look very nice. At least then the site admin can simply change the location of the block in the block settings. Less confusion, less risk of important block data being overlooked.

+1 to #11 for its light touch.

ontwerpwerk’s picture

fgm: it works, but place a login block there and you'll see

Stefan Nagtegaal’s picture

To be honoust, I think we should get rid of the whole default regions and let every theme itself define the regions it wants to use..
Themes are designed for with some purposes and functionality in mind, and so it becaomes quite hard to define a default set of regions to rely on..

Stefan

webchick’s picture

FileSize
63.3 KB

@ontwerpwerk: then don't put a login block there. :P I usually use it for ad banners and it looks fine. See screenshot. An "announcement" message is another suitable use case, as fgm points out.

@stefan: -1. That's forcing a PHP requirement on people to create themes. At the very least, they would need to change the name of an existing theme_name_regions() function in order to see any regions at all.

webchick’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
725 bytes

Re-roll of Moshe's patch in #11 with indentation fixed. Marking RTBC because:

- Removing the header region from all of core is not a fix.
- CogRusty's patch would make Garland less hackable.
- chx's patch changes APIs.
- fgm's patch adds some borders and stuff which I don't think fit every use case.
- It looks as good as any other theme's header region (see screenshot in previous post).

ontwerpwerk’s picture

I agree with webchick above. Not all blocks will look good, but for backwards compatibility and banners this is a good solution.

fgm’s picture

FileSize
1.09 KB

Webchick: I hadn't thought about the "image" use (banners) you describe so your version is more usable for that case. I still think the "header" should go below the mission, though. It won't affect non-home pages, and mission has some semantic reason to be the topmost content.

IMHO, order should be:

  1. mission
  2. header-region
  3. breadcrumbs

So here is the rerolled version with that order applied.

webchick’s picture

fgm: That would work, except the other core themes always have $header before $mission, so for consistency we should keep it that way.

ontwerpwerk’s picture

fgm: you are right in your situation, but this theme's use will be primarily for new users and users who were fine with bluemarine before. The people who want different behaviour are encouraged to make their own theme and modifications.

That's why I believe the patch by webchick qualifies as a 'good enough' solution and should be committed. (and lets not discuss the color of this particular bikeshed any longer...)

chx’s picture

#27 is fine with me.

fgm’s picture

For consistency's sake with pushbutton and bluemarine, #27 is good for me too.

Steven’s picture

Status: Reviewed & tested by the community » Needs work

Placing blocks where the mission is, is atrocious. It breaks the visual proximity of the breadcrumb, page titles and local tasks.

moshe weitzman’s picture

Status: Needs work » Reviewed & tested by the community

@Steven. Most everyone agrees - thats why #27 is the leading candidate. I think you reviewed #29.

Steven’s picture

Status: Reviewed & tested by the community » Needs work

I was talking about the screenshot that webchick submitted.

Steven’s picture

Status: Needs work » Needs review
FileSize
2.43 KB

I don't see a problem with removing the header region by default. People who used it before can still add the region to their custom theme in 5.0. Just because this technique is not appropriate for a core theme, doesn't mean it cannot be used in contrib or on your own site.

But, to actually stop the bickering, there is an alternative which I've attached. It adds the header region to the top of the page and includes some trivial CSS to make blocks look at least not completely horrible when placed there. But I'd still prefer just removing the region.

Arbitrary changes to Garland like proposed earlier are not acceptable. If we want maintain a high quality standard in Drupal, all patches that alter the way it looks and acts must include the appropriate CSS to keep it pretty. We have been too lax about this in the past (e.g. when Form API screwed up the spacing between checkboxes/radios in groups) and this must change.

For 6.0, we should add .info files to themes, where info like regions, features and even color.module info can be defined. The set of regions that is now defined in phptemplate.engine should be moved to theme.inc and become the global default for all themes. By not relying on PHP code, we can avoid function names clashing when querying the info of a theme other than the current one.

drumm’s picture

We can implement garland_regions() in its template.php.

Putting the header above the site title may or may not be the best place. Depends on what people would like to use it for.

Steven’s picture

Using garland_regions() in template.php means the theme cannot be copied freely without hacking the code. This has been mentioned several times in this thread already.

drumm’s picture

I'm okay with this patch. Any other reviews?

chx’s picture

Status: Needs review » Reviewed & tested by the community

What could be better than supporting header regions in Garland -- implemented by the very author of Garland himself?

cog.rusty’s picture

True, and we can still hack "if $mission" for our atrocious banners.

Dries’s picture

Haven't tested it, but the code^^^CSS looks sane.

webchick’s picture

FileSize
49.47 KB

For the visually inclined, the banner now looks like this. Kind of seems like maybe the padding on the top and bottom should be consistent, but I'm not going to fight it much, as at least it's there now, and I could always tweak the CSS myself. :)

Dries’s picture

Looks better than the previous screenshot, but I agree with the padding issue. It's cramped at the top.

webchick’s picture

FileSize
37.23 KB

k, I changed:

  margin-top: 0;

to:

  margin-top: 0.5em;

in:

#header-region * {

And now it looks like this, which to my untrained eye looks right. Patch coming up in a second. Will have to mark back to "needs review" as it needs Steven's approval.

webchick’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.44 KB

Patch.

Steven’s picture

Webchick:
Setting a top margin on every single element inside the block, just to fix the banner, seems stupid. The banner's own styling should already provide an equal spacing at the top and bottom.

Other blocks, such as User login, or Who's Online look fine in the header region without your addition.

webchick’s picture

Status: Needs review » Reviewed & tested by the community

Ok, set back to RTBC for #37.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Patch in #37 no longer applies, I think cos of the CSS url() cleanup patch.

webchick’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
2.42 KB

Re-roll.

Steven’s picture

Status: Reviewed & tested by the community » Fixed

Added the 0.5em top margin to paragraphs and image tags. That should help space things out.

Committed to HEAD.

webchick’s picture

FileSize
43.12 KB

Looks great now, thanks!!

lyricnz’s picture

What's the consensus about hiding region DIV tags when there's nothing in them? The current behaviour leaves a (ugly) empty space at the top of the page if there are no blocks in the header. How about:

<!-- Layout -->
<?php if ($header != "") { ?>
  <div id="header-region" class="clear-block"><?php print $header; ?></div>
<?php } ?>
Steven’s picture

The space at the top is intentional, and was there before this patch as well.

Anonymous’s picture

Status: Fixed » Closed (fixed)