While writing http://drupal.org/node/125640#comment-1072128, I also have some ideas I'd like to share and to hear, before really going deep into the code, any developer's thoughts about this:

I know the token replacements are designed to be rather simple to use and simple to process, but what happen when something else is needed? The only thing I am thinking about right now is conditional tokens, for instance, I'd like something to be replaced, but if that data is empty, I would like a default string to be used instead.

Now I can think of some syntax like:
[TOKEN?DEFAULT]
which can be worked out within the token API

but also I am thinking that a better way of defining module's tokens (tokens that will be processed by modules) would help do this without messing or compromising the current API that much, and giving any module the flexibility to do more complex replacements.

I am thinking in something in the line of defining either tokens with wildcards or token with regular expressions. Probably wildcards is simpler and less error-prone. If I (a module) is given the possibility of define token with wildcards, like: [TOKEN_MODULE*] and the token core triggers the token_values() hook if any token that matches that wildcard through my module, I can really do any replacement in my own module, working out a custom or propietary syntax to do default replacement or quite any other thing.

What do you guys think?

Comments

greggles’s picture

Status: Active » Closed (won't fix)

I think this is discussed in #354039: Token logic module patch. Sorry for not responding sooner.