eternalistic
5/28/2014 - 3:55 AM

Hide page title based on field checked on node.

Hide page title based on field checked on node.

/**
 * Override or insert variables into the page templates.
 *
 * @param $variables
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("page" in this case.)
 */
function facing_history_preprocess_page(&$vars) {
  // Node page preprocess.
  if ($vars['is_front']) {
    $vars['title'] = '';
  }
  if (isset($vars['node'])) {
    $page_wrapper = entity_metadata_wrapper('node', $vars['node']);
    $show_title = $page_wrapper->field_page_show_title->value();

    if (empty($show_title)) {
      $vars['title'] = FALSE;
    }
  }
}