Currently, there's no way for one module to alter the list of tokens defined by another module.

For example, if module_a defines a token like "username-url" whose value is a link to the user page with the link text "Click Here For My User Page", there is no way for module_b to replace that link text with, for example, values from the user's profile.

This patch adds a drupal_alter() call to token_get_values() so that other modules can intercept and adjust already-defined values as necessary.
D7 already handles this in token_info() and token_generate() using drupal_alter(), but the same functionality was never backported.

Is there a better way to do this in D6 that I'm overlooking?

I haven't followed the discussion on this, and a quick search on the queue didn't turn up much, so please forgive me if i'm re-treading old ground.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Title: Use drupal_alter() to allow altering of tokens » Add hook_token_values_alter() to allow altering of tokens
Status: Active » Needs review
FileSize
2.08 KB

Revised patch with documentation in token.api.php. Uses the same D7-style $context since it's easier to document.

TonyK’s picture

I've tested patch from #1 and it worked good. Anyone else? This feature is really useful.

davidwhthomas’s picture

This would be great in the D7 version too.

TonyK’s picture

@davidwhthomas, description says it's already implemented in D7.

ebeyrent’s picture

Any chance of getting this committed any time soon?

Dave Reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.