Hi,

Thanks for this great module... I am trying to access the title tag as processed by the metatag module in my template. For example, in node--article.tpl.php if I use

drupal_get_title();

I will get the straight node title, i.e. the metatag module seems to kick in AFTER. What I'm trying to do here is just to try to GET the final Title value in my template...

Same if I try to set the title with drupal_set_title()... any title set there will be overridden by the metatag module afterwards...

Any ideas?

Comments

DamienMcKenna’s picture

Status: Active » Closed (won't fix)

Honestly it sounds like you're trying to this the wrong way, you shouldn't need to obtain the page title.

What are you trying to do with the page title?

bohemier’s picture

Hi Damien,

Thanks for your reply. It's very much appreciated. What I'm trying to do here is to have access the final title as processed by metatag in my node. For instance, for a node type, I have a combination of fields, the title and the site name (ex: [node:field_number] [node:title] | [site:name]). And for another node type, I might have just the page title followed by the site name ([current-page:title] | [site:name]). This title is needed in the page for my social sharing widgets. For example, at the bottom of my page I put an "Email this page" link, with the following url:

mailto:?subject=[current-page:title]&body=[current-page:url]

What I'm getting here for the token [current-page:title] is just the default page title which is not the final page title as processed by metatag. What I would really need is something like

mailto:?subject=<?= drupal_get_title() ?>&body=[current-page:url]

or even better with token support:
mailto:?subject=[metatag:title]&body=[current-page:url]

But there seems to be no way to get the output of the metatags at this point in a template file as the processing seems to occur afterwards.

I could replicate my title configuration in my nodes but you can imagine the administrative mess it can lead to.

What I did for now is to use javascript to get the page title (document.title), but this isn't ideal...

Thanks your help!

Cheers

bohemier’s picture

Issue summary: View changes

typo correction