[support] Proper use of tokens (D7)

Earnie Boyd earnie at users.sourceforge.net
Thu Jan 17 14:52:29 UTC 2013


<quote>
This hook is invoked when someone calls token_replace(). That function
first scans the text for [type:token] patterns, and splits the needed
tokens into groups by type. Then hook_tokens() is invoked on each
token-type group, allowing your module to respond by providing
replacement text for any of the tokens in the group that your module
knows how to process.

A module implementing this hook should also implement
hook_token_info() in order to list its available tokens on editing
screens.
</quote>

I think it should be fixed but it shouldn't hurt for the time being.

Earnie

On Thu, Jan 17, 2013 at 9:43 AM, Ms. Nancy Wichmann
<nan_wich at bellsouth.net> wrote:
> I have been trying to work with a [popular] contributed module. I have found
> a few things that were less than well converted to D7. One that I am trying
> to decide whether or not to fix is in hook_tokens(). In this hook, the
> second parameter indicates which token replacements are being requested.
> This implementation still returns ALL token values, as one did in D6. If you
> look, for example, at system_tokens(), it looks like the "correct" function
> would return only the requested tokens. Returning them all should still
> work, but I am concerned that at some point in the future this might become
> an error.
>
> Do you think a significant overhaul in this module should be done, or is it
> okay to leave it as is and return all possible token replacements?
>
> Nancy
> Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King,
> Jr.
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]



-- 
Earnie
-- https://sites.google.com/site/earnieboyd


More information about the support mailing list