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.
Comment | File | Size | Author |
---|---|---|---|
#1 | 1157058-hook-token-values-alter.patch | 2.08 KB | Dave Reid |
token-drupal_alter.patch | 444 bytes | AaronBauman | |
Comments
Comment #1
Dave ReidRevised patch with documentation in token.api.php. Uses the same D7-style $context since it's easier to document.
Comment #2
TonyK CreditAttribution: TonyK commentedI've tested patch from #1 and it worked good. Anyone else? This feature is really useful.
Comment #3
davidwhthomas CreditAttribution: davidwhthomas commentedThis would be great in the D7 version too.
Comment #4
TonyK CreditAttribution: TonyK commented@davidwhthomas, description says it's already implemented in D7.
Comment #5
ebeyrent CreditAttribution: ebeyrent commentedAny chance of getting this committed any time soon?
Comment #6
Dave ReidCommitted #1 to Git.
http://drupalcode.org/project/token.git/commit/a7cdf54