Tokens
The Token module for Drupal 4.7 and 5 exposes simple text substitution tokens like [title] and [user-name], for use in path generation, mass mailings, and many other situation where admins want to set up text replacement patterns without using PHP snippets. Other modules can expose their own domain-specific replacement tokens (like information about a purchase, or an organic group that a user is a member of) and use Token's centralized replace() function to replace token occurrences in any piece of text.
If you are curious how you might use tokens or who is using it, consider this list of modules that use token
Replacement Patterns Not Available
Greetings,
I'm new to this group and to the Token module, so forgive my ignorance with this question. Its possible I missed something basic. I am unable to see and replacement patterns anywhere on my site where they should be listed. For example the Auto Nodetitles module provides a fieldset which is supposed to list the available replacement patterns, but there isn't anything in the fieldset (attachment1). Its also not replacing my [field_event-raw] with anything. I have the same issue in the Workflow-ng pages, nothing shows up (attachment2), but my tokens ARE being replaced.
5.x-1.11 Pre-release Bug Tracking Wiki
Howdy folks,
I think (and karen thinks) that we've hit the time for a 5.x-1.11 release. Are there any major bugs we should fix prior to that release? Can anyone else confirm that the 5.x-1.x-dev release is working well for them (I use it on all my sites, but I don't exercise all of its features...) Post links to the issues in this wiki or as comments on this page. If you think it's ready to go, posting a message saying that would help as well! Thanks!
Vocabulary Index paths & Token
Somewhere in fall 2007 I started working on Vocabulary Index. The 1.0 version has been available for some weeks now and I have already started working on 2.0 (although a final won't be released for a few months. It's mostly brainstorming at this time).
format_date? which timezone to use?
There's an issue with some of the dates in tokens that they don't get set to the right values.
Of course, the question is what's the "right" value?
I'm writing here to ask if you'd rather get the server time or the default site time or the user's timezone.
The first person who asks for "configurable by the token admin" will get stabbed with a "work on token2.x where attributes are possible"-spoon. (yes, a spoon, it will hurt more).
Arbitary tokens
In the last two days I whipped up a very quick module that allows you to create arbitrary tokens (i.e. /node/add/token) for use with the token modules. This was primarily created for use with the tokenize module so that through the UI a user could create tokens and select which fields could use those tokens.
Token and the Rep[lacement]Tags module
I'm author and maintainer of the Rep[lacement]Tags module (http://drupal.org/project/reptag). As mentioned and explained before the reptag module is a regexp-based, node-centric, bigger brother/sister of the Token module. The idea behind both modules is quite similar and even the API is similar on some points. For Drupal 6 I'd really love to see the modules complement each other (or even merge). To achieve that (at least for most of the features) only a few changes to Token and some more to Reptag ;) would be required.
Modules that Use Token Module
Here is a list of some of the modules that use token. If you know of another, please add it.
Some of these modules provide tokens, some just use the token_replace mechanism. But if you are looking for something that will integrate nicely with (for example) Auto Node Title, Page Title, or Pathauto (the consumers of tokens) then you should consider these modules which will probably expose their inner data as tokens to other modules.
Another token enhancement proposal
Token should probably provide an easy way for modules to create tokens based on already existing tokens. Let me explain what I mean. For a node, I should be able to pass in 'author-' as a prefix, 'user' as the type, and the node's author as the object. Token would then get all the values for 'user' with the object $user, and would return them as the tokens [author-usertokenpropertyhere].
Token enhancement proposal
Token is great, however there are still some problems that need to be solved. Here is a proposal, which tries to do so.
Problems I noticed are:
- missing handling of multiple values
- no way to get tokens of a certain node type and no more
- no way to get token help for only raw values or formatted ones - which might lead to XSS created by unexperienced users
- performance: getting all token values for a node takes about 10ms!
I ran over the performance issue while developing workflow-ng. I think 10ms just for replacing a token is far less than ideal. I noticed that user tokens are working quite fast, so I assume that getting and caching all token values takes that long. So I propose to do the replacing in two steps, first off it is determined for each token, if it has been used.Then on the second step, the value for each used token is determined and replaced.
So token needs to get only the values for really use tokens - this should work fast!
Unfortunately, this and the improved formatter handling requires API changes. So consider this as a proposal for token 2.x.
Barcelona Event
Following Dries' request for more presentations I decided that Token module would be a good topic:
Token Module: How I Learned To Use the Token API and Stop Re-Implementing Dynamic String Replacement
So, if you are headed to Barcelona and want to learn more about using Tokens, this would be a great session to attend. Similarly, we plan to use some of the time to talk about the "future of tokens" which should hopefully be a useful topic.
The future of tokens?
Wow. Pathauto finally made the move!
Token module was conceived when I was writing custom_breadcrumbs and custom_links, and wanted to generate the kind of simple [foo] and [bar] links that had been popularized by Pathauto. I was this close to listing pathauto as a dependency for both modules when I ran into greggles in #drupal and started chatting with him about the need for a centralized 'Just The Tokens' utility that many modules could benefit from.
With the current release of Token module, and the current release of Pathauto, quite a few modules can now plug into "the system."







