0

I've just discovered that Drupal 8 Bootstrap theme doesn't implement all existent hooks. So, for example, hook_theme_suggestions_page_alter() works, but hook_theme_suggestions_node_alter() doesn't work.

I'm interested on hook_preprocess_page_title(&$variables) and I wonder if it's possible to incorporate this hook into my custom Bootstrap sub-theme. I have created the page-title.html.twig template and cleared the cache.

I saw https://drupal-bootstrap.org/api/bootstrap/docs!plugins!Preprocess.md/group/plugins_preprocess/8.x-3.x but it seems this is for extending an already existent hook in Bootstrap theme, not for adding a new one.

How do I add hook_preprocess_page_title() in a Bootstrap theme?

-1

How do I add hook_preprocess_page_title() in a Bootstrap theme?

In your sub-theme's .theme file you add:

/*
 * Implements hook_preprocess_page_title()
 */
SUB_THEME_NAME_preprocess_page_title(&$variables) {
  // your logic goes here
}
  • as I mentioned before that doesn't work on my Bootstrap subtheme :-/ – leandro713 Nov 18 at 10:06
  • Did you check if the hook is firing? ex: put inside of it \Drupal::messenger()->addMessage(t('testing.'), 'error'); – No Sssweat Nov 18 at 10:10
  • yes, I've checked it and the hook is not being fired, i answer because of this. – leandro713 Nov 18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.