0

Why do I get to the breakpoint in MYMODULE_preprocess_page_title but not in MYMODULE_preprocess_page?

What I am tying to achieve is to update page title both on the top of the page and in the browser title bar/tab name.

The following code only affects the title on the top of the page.

function MYMODULE_preprocess_page_title(&$variables) {
  $variables['title] = 'Something Different!';
}

I've read some people are saying hook hook_preprocess_page instead to update both.

I tried to find what are the available hooks like hook_preprocess_blabla starting here, but couldn't find my way in the documents to the list of available hooks.

0

both should work on custom MODULE or THEME

function MODULENAME_preprocess_page(&$vars) {
  //do stuff
}

function MODULENAME_preprocess(&$vars, $hook) {
  if($hook == 'page') {
    //do stuff
  }
}

You need to rebuild cache and at least when using netbeans be careful not all lines will trigger the breakpoint ... for example I have noticed that multiline array definitions will not trigger it. Post your code for more details

  • Thanks Giorgos, I refreshed the cache and it is now hooking. I thought I've turned off all caching in dev settings, why is this still needs clearing cache? The second thing is setting the title, now it is not set from hook_preprocess_page. Any idea? My code is not that different than what is above, except for the code that prepare the value for the title and of course the code that checks if this is the correct page. – Bishoy Nov 13 '17 at 11:21
  • When in doubt always clear the cache. – Kevin Nov 13 '17 at 14:12

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.