There are a number of ways to do this, but this answer focuses on the considerations for handling things programmatically in custom code.
The <title>
variable (for the browser title bar) is calculated as part of the "html" theme template, while the <h1>
title variable (printed at the top of the page) is calculated as part of the "page" theme template. So in this regard if you implement some preprocess logic on the "page" output, you can remove the title from the page display while still keeping it intact for the browser bar. This is of course in contrast to more heavy-handed approaches, like calling drupal_set_title()
, which impact static variables that may apply on a more global scope.
The trick to this is that, in most cases, your "page" template title is not actually initiated as a theme variable until template_process_page(), which runs after any preprocess functions. So you may not see a "title" variable within the scope of your own theme_preprocess_page(). The appropriate snippet from template_process_page(), where the title is added, is just:
if (!isset($variables['title'])) {
$variables['title'] = drupal_get_title();
}
Given this background, you could manipulate the title variable direct by either:
- Setting $variables['title'] to an empty string within your theme_preprocess_page() (based on whatever conditions your desire). This way it will be set and therefore won't get filled-in via the template_process_page() code that runs later, but it will still be empty when page.tpl.php template renders things.
- Implementing a theme_process_page() function, which will run after template_process_page(), that unsets/nullifies the title variable set there.
You could also avoid touching the title variable itself altogether by just setting a boolean flag, like $show_title, in a (pre)process function. Then you would need to modify your page.tpl.php template with a very basic boolean check of $show_title that only prints the title <h1>
if TRUE. That method is discussed in this post.
With any of these options you isolate your primary conditional logic, which can be as detailed as you want (should you discover new title visibility needs later), within the theme preprocessing layer. This will help keep things more maintainable for the long run.