Hiding the node:title field but still having it available (using Omega theme in Drupal 7)

I have a Drupal 7 install for a site I’m building, and am using an Omega subtheme. Due to the site’s layout, I’ve needed to place the node title in a different zone (and am using Views to do this) in one of my content types. I needed to hide/remove the node title from the main content area, but wasn’t sure of the best method of doing this. I could just do a “display: none” in the CSS for that field, but it doesn’t seem like good practice to have two identical H1 tags in the content, with one hidden. I tried installing a module called Exclude Node Title, and that worked for the most part, except I also have the Meta Tags module installed, and the node:title field no longer showed up in the meta title field. Looks like this is a reported bug for that module, so this module may be a solution for this issue in the future. On a related note, I’d love to see the title field added to the “Manage Display” page for every content type! That would eliminate the need for this module.

I had the thought of editing a tpl file to make this work, and figured out that this field lives in region–content.tpl.php. Based on what I’ve found looking around online though, I can’t duplicate this and make a version that is specific to that content type. I did find a workaround for this, however – I created region–content–page.tpl.php (as I’m doing this for the “page” content type), added that to my “templates” directory, and edited the HTML around the H1 tag.

Then, this code goes into preprocess-region.inc:

function [yourmodule]_alpha_preprocess_region(&$vars) {
  $menu_object = menu_get_object();
  if (isset($menu_object->type) && $vars['region'] == 'content') {
    if ('page' == $menu_object->type) {
      $vars['theme_hook_suggestions'][] = 'region__content__page';
    }
  }
}

Clear your caches, and this should work!

On a related note, this may also be something that you can do with the Display Suite module. Though, since I just needed to do something tiny, I figured a chunk of code or two would be a more lightweight solution than adding another module.

Leave a Reply