7 - Can't update page titles I'm currently working on a project on which I'm trying to dynamically shorten the pages titles as following:

"This is very long text blahblahblah | Site Name" becomes "This is very ... | Site Name" but the rendered page doesn't take this into account.

Here's my problem: I tried several hooks to implement this behaviour, using hook_menu_alter(), hook_preprocess_html(), hook_node_preprocess(), etc. and I followed the indications given to update the pages titles when using these hooks, but it always falls back to using the original long title. 

Actually, when I set the arrays accurate keys/values, would it be $vars['head_title'], $vars['title'], etc. I can var_dump the array and verify the needed variable is updated, but the title is untouched. Using drupal_set_title($new_title) didn't help either.

I'm quite puzzled; would this be because I'm using Custom Field, Metatag, or a specific module? Or would this be because I'm not updating the page at the correct moment during its generation? Drupal is somehow new to me!

Thanks a lot :)

~Steph
OK! After going back and forth between var_dump's, installed modules list and hooks, I discovered that the ONLY hook that will update the page's tags is hook_metatag_metatags_view_alter(&amp;$output), in which something like this needs to be done:

$output['title']['#attached']['metatag_set_preprocess_variable'][0][2] = "Custom title";


My n00b diagnosis is that this hook is called right after the last Metatag module's function that rebuilds the metatags from scratch, and therefore it's the only one that matters.

Hope this will help others! :)

~Steph