1

I am using Drupal 7 with the Metatag module along with the Page title module.

I have a requirement to build the title of a custom content type using some node fields and additional conditions that I can't reproduce using the tokens provided, so I have hooked to the page title API ( hook_page_title_alter(&$title)) to build my custom title only for one node type.

The function works and the page title is set. But the meta tags are wrong, they are not using the page title found in <TITLE> (under <HEAD>) but the node's title which I don't want to use.

How do I feed metatags module with my custom title ? I am out of ideas, so anything is appreciated.

As commented by someone you don't need the page_title module if you use metatags, but page_title provides an API with hooks to alter the page title, and that's what I am using and what I need to use, so maybe the question could be reformulated to "How do I alter the page title generated by metatags?"

  • 2
    There is already 'Page title' configuration with 'Meta tag' Module. You do not need to install separate 'Page title' module. – Jayendra Kainthola Oct 28 '13 at 10:13
  • So the hooks already exist in the metatag module ? I will take a look. – drcelus Oct 28 '13 at 10:27
  • The API hooks for altering the title are not present in the metatags module, so I need both. Or a hook elsewhere to modify the metatags title ... – drcelus Oct 28 '13 at 16:07
  • Are you using Drupal 7? – Jayendra Kainthola Oct 29 '13 at 0:02
  • Yes, Drupal 7 (edited). – drcelus Oct 29 '13 at 6:53
2

It is indeed a bad idea to have both modules altering the page title. A better approach I have found is to create a custom token, (which is really trivial with the provided example) and use it inside a metatag configuration for the desired node type. This way page_title could be uninstalled since it's no longer needed.

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.