Skip to content

Instantly share code, notes, and snippets.

@jeremycaldwell
Created June 15, 2021 17:44
Show Gist options
  • Save jeremycaldwell/14e3d93554d38bd093b5bf4680372ee8 to your computer and use it in GitHub Desktop.
Save jeremycaldwell/14e3d93554d38bd093b5bf4680372ee8 to your computer and use it in GitHub Desktop.
/**
* Implements hook_preprocess_HOOK() for page title templates.
*/
function THEMENAME_preprocess_page(&$variables) {
$node = \Drupal::request()->attributes->get('node');
if (isset($node) && $node instanceof Node) {
// Check node types and remove the block title.
switch ($node->getType()) {
case "bio":
case "form":
case "page":
case "product":
case "product_subpage":
case "static_page":
case "support_download_page":
unset($variables['page']['title']);
break;
}
}
// Unset the page title for webform thank you pages.
$route_id = \Drupal::routeMatch()->getRouteName();
if ($route_id === 'sophos_webform_confirmation.confirmation') {
unset($variables['page']['title']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment