Hi, thanks a lot for your module (you may want to add ejournal.module into into your list)

I was wondering if you could add support for token_replace for all the types - because, I cannot query the available types of objects, it seems to me to be overhead to use tokens_find_all, I would like to just call your function like "token_replace($string, "alltypes")

roman

Comments

greggles’s picture

Title: quering the types » hook_token_values should handle "all"
Category: support » bug

I think that token_replace($string, 'all') should do that. In practice, it doesn't do it all of the time...it depends on the individual hook_token_values implementation as to whether or not that will work. If a module doesn't respect the 'all' then there should be a bug filed against the specific module.

Since the token module doesn't respond to that properly I'd like to turn this into a bug against token...

avpaderno’s picture

Category: bug » feature

I find quite difficult to pass 'all' to the implementation of hook_token_values(). Which would be the value assigned to $object in that case?

Then, there is already the token_replace_multiple() function. What is the purpose of having token_replace() that passes 'all' to hook_token_values()?

dave reid’s picture

Status: Active » Closed (won't fix)

This isn't a good idea. If you need to you can run the token functions more than once. :)

Equinger’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

I'm going to weigh in on this a year later! Basically, the reason for this feature is that contributed modules like "Messaging" can call "token_replace_multiple" which implicitly defines related objects for an event like sending out a notification, but there is no way to build a token that takes into account the interaction between objects. For example, right now I can only deal with "node," "user," "comment," and "event." The user is actually the user who is being sent the notification and the node is the node that he/she is being sent a notification about. The user clearly has a special relationship w/ that node (aka ... how many comments are NEW to that user on the node). It's a good possibility that I don't have enough imagination (or done enough research) on other ways to resolve this issue, but this would seem like the lowest hanging fruit.