2

I have custom tokens defined in hook_token_info() and hook_tokens(). I need these tokens to populate metatag data for the metagag module on a custom path. I have the context module installed as well.

The path routes to a callback that loads the object I need to pass to token_replace().

My question is when and where do I call token_replace() so the tokens are available to metatag context on page load?

0

The correct place to specify the replace data was in hook_tokens(). I did not follow the original tutorial correctly and thought since my tokens were not available I was in the wrong place.

I ended up specifying my tokens as the current-page type. After I did that, they displayed and I can now use them for my metatags.

As a side note, I did discover you need to run cron after you make changes to hook_token_info().

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.