jeudi 5 octobre 2017

Drupal 8 - Hook to Change Page Title

I want to programmatically alter a page title in Drupal 8 so that it will be hard-coded in the theme file.

I'm attempting to use a hook function to preprocess_page_title, but it seems to not understand what page to change the title on.

Here's what I have so far:

function test_preprocess_page_title(&$variables) {
  if (arg(0) == 'node/12') {
    $variables['title'] = 'New Title';
  }
}

I figured the only way to make this change on one specific page is to set the node argument. Has any one figured out a way to override page title on Drupal?

Aucun commentaire:

Enregistrer un commentaire