I can't seem to find a way to override (or empty) the title of the content region generated by the following link in region--content.tpl.php

<h1 class="title" id="page-title"><?php print $title; ?></h1>

I looked around omega, and I think this is because $title is set right at the end of the theme layer, in omega_alpha_process_region() in omega's template.php. I thought that was the type of thing you are supposed to have access to at the preprocess stage. I must be missing something here...

Note that I obviously do not want to do this kind of logic in the tpl file... but higher up in some preprocess function.

Comments

himerus’s picture

There are some contrib modules that manipulate this in preprocess layer, and we ran into problems with putting this in preprocess before....

the BEST way to accomplish this would be to disable the page title completely in the theme settings, and place it using a block using either Blockify or the Delta Blocks module (included with Delta)...

Since "all" things should be moving to blocks in D8 (that didn't get into D7) this is kind of a best practice moving forward...

it is possible to do any overrides needed simply using the process_region in your subtheme, and I don't see a real reason that makes it necessary that it (or anything) be done in preprocess as opposed to process... although I end up moving most things i build in hook_process back into preprocess after getting it all to work right.

scor’s picture

thanks for prompt response Jake!

it is possible to do any overrides needed simply using the process_region in your subtheme

adding $vars['title'] = 'my custom title'; to my subtheme preprocess/preprocess-region.inc has no effect. In fact, I can trace my custom string all the way to right before it gets overridden omega's template.php.

btw, this function is named omega_alpha_process_region() in omega's template.php - am I looking at the wrong place? what's '_alpha_' doing in this function?

himerus’s picture

can you put it though in process/process-region.inc instead?

I forget the "exact" reasoning behind Fubhy's introduction of the THEME_alpha_(pre)process_HOOK... I know there was a very good one based on the build structures in core, and this ensuring that things were appropriately passed around... hopefully he can chime in on that logic... I'd have to reread alpha.inc again, and every time I do, it makes my head spin.

I've taken the stance that EVERYTHING should be a block... it seemed D7 was going that way (with content moving to a block) but also the logo, the site title, slogan, tabs, messages, and even the page title... I was using Blockify religiously, but didn't like some of the implementations they used, so we created a similar functionality in delta_blocks to work just the way we wanted.

So for all my projects, I disable ALL theme output of main & secondary menus, tabs, page title, etc. They ARE still in the theme because a good percentage of users need to be able to see all those elements out of the box when turning on a theme, otherwise.... "whoa... this is broken" would be the title of many issues in the queue.

I really think using one of the modules that replicates all core elements in blocks is a good idea... then no odd behaviors "should" occur...

But otherwise, attempt your custom page title code in process/process-region.inc, and see if that fixes it...

scor’s picture

can you put it though in process/process-region.inc instead?

doh! sure, works that way!

I was initially trying to massage this into a module, but this won't work since MODULE_process_HOOK() runs before THEME_process_HOOK() :(

There are some contrib modules that manipulate this in preprocess layer, and we ran into problems with putting this in preprocess before....

I'm not a themer, so maybe I'm completely off here. I don't know what kind of problem you are talking about here. But isn't the point of the theme layer to let modules/themes alter the page markup before it's rendered? The way I understand this, is that base themes (like omega) set a value like title, and module/sub-themes get a chance to alter its value afterwards... waiting until the end of the cycle (process) to expose this title value defeats the purpose of the theme layer. Isn't it how it's supposed to work? (value are set early, and the Drupal eco-system gets to pick at it in preprocess and process steps).