Welcome
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
If you want to help get Token into Core then there's the issue. Please don't just subscribe to the issue or you will lose karma points in the eyes of some of Drupal's most respected community members.
Token contrib module issues
Token replacement from specific vocabularies?
I've got a content type with a Name field, and 2 taxonomy vocabularies applied, one for "person type" and one for "issue type". I'm using auto node titles module, and I want to to format the titles like this
[name], [person type], on [issue type]
e.g.
Andy Laken, Volunteer, on Governance
But in the replacement pattern list, I find only [term] which is the "Name of top taxonomy term" (not sure what that means.) My question - is there any way to get a replacement pattern to grab the name of the term for a specific vocabularies, when more than one vocab applies to a node?
Read moreToken and CCK nodereference
Hi All,
Thanks for a great module. I'm trying to make pathauto construct hierarchical urls using cck-nodereference fields for the hierarchical relationships. And I have some questions about the tokens that are created for nodereference fields. As far as I can see the only usable token is [fieldname]-nid. Is this correct, or are the *-title and *-link tokens populated in certain circumstances?
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!
Read moreformat_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).
Read moreArbitary 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.
Read moreToken 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.
Read moreModules 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.
| Module | 5.x | 6.x | 7.x | 8.x | 9.x | 10.x |
|---|---|---|---|---|---|---|
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].
Read moreToken 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.
Read more




