Can't set Page Title inside hook_preprocess_page? Hack it!

Published July 13, 2009

If your client is being very picky about the titles of certain pages, especially views, you may find yourself needing to write some code to set the title at the theme level. This is normally fine, since Drupal 6 has some great hooks, like hook_preprocess_page() and its cousins for blocks, nodes, and user profiles.

This should be the right place to call drupal_set_title() and be on your way, but you may not get the expected results. This may also apply to any functions that place output in the header of the HTML, like CSS, Javascript, Feeds, and Meta tags.

A workaround is documented on the CivicActions blog involving hooking into the theme registry and adding a function very very early in the process to help you set the page title appropriately.

Link: Can't Add CSS, JS, RSS Icon Or Set Title Or Messages In Preprocess Page?

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA