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

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.

Use page URL as Token

Hi,

I just want to use the URL of the current page as a Token with Views (for ?destination=...)
I've been searching for hours, tried different modules (like tokenSTARTER) but it didn't work.

Help! Why is it that difficult?
Thanks a lot.

P.S. Sorry if using the forum would have been better but I thought I'd better ask the guys who made it...

1 comment

Tokens and Domain

Hi, I am intensively testing Domain.module and have noticed that in the Modules that Use Token Module the Domain Access module is not listed. It would be interesting to know if there are some issues about or any kind of feedback you may know about, that may be related to the 2 modules installed togheter. Feedback very much appreciate.

Login to post comments
greggles's picture

new releases of token

It's about time for a new release, right?

If you are on of the people interested in this, please head on over to issues to fix before a 6.x-1.12 Release to help finalize the 2 remaining patches and suggest any issues that you'd like to see fixed prior to the release.

Login to post comments

user_pass_reset_url token

I am trying to use the CCK+Rules+Token module to accomplish creation of a user when a content with its email address is being created.
This user should get an email notification with his password and/or a user_pass_reset_url link.

The token_user.inc does not provide password, nor the creation of the user using the rules action.
In addition, the !password of the user_mail_tokens does not apply here.

Any suggestion what should be the right way to solve this ?

Regards,
Shushu

5 comments
fago's picture

Tokens & RDF in d7 - can they benefit from each other?

Right now there is a issue for getting token into core and one for getting some RDF into it. I wonder if makes sense to base the token patch upon the RDF stuff. So once we have some semantics attached to our objects, we can use them as a starting point for doing the token replacements.

The other way round, the RDF patch could learn from the tokens code - as the actual problem to solve is quite similar. The way the patch in #74 uses simple handlers to get tokens would make sense for RDF too. Then the token implementation can go and build upon that and reuse the handlers returning RDF string literals. Similarly, the approach described in #77 for doing actual token replacements could also be used for getting chunks of RDF for a bunch of objects.

Then apart from avoiding inventing the wheel twice, we could easily make both APIs consistent, so they can be used the same way.

Login to post comments
sirkitree's picture

Better token lists

Has anyone come up with a better way of presenting the list of tokens to users? I'm finding that what I'm doing is really ugly and would love to know if anyone has seen any good examples of how to present tokens in a more usable manner.
Configure an advanced action | Community

8 comments

Possible New Drupal Modules

Possible New Drupal Modules

I have a few ideas for Drupal modules. All are related to Social Networking Sites in that they are an attempt to allow nodes to appear as if they are part of each users account. The first and third modules are related to the Token module.

I'm anticipating developing these modules for Drupal 6 and later versions of Drupal. Not for Drupal 5. I've done some work towards the first module (Type user nids) but very little for the other two.

I'm asking the following:

1) Are these likely to be useful to the Drupal community?

6 comments · Read more
flickerfly's picture

Using tokens in a menu link

I have a menu item that I'd like to make different for each user. It's an internal page that accepts &_GET in the URL.

I'm thinking I could skip the user past entering this information in manually by providing the url like http://site.com/?user=loggedinuser&target=somepage. Could I fill this username with the drupal username using a token or are they just not available in the context of menu entries?

How else could I solve this if not with tokens?

15 comments
greggles's picture

New releases of Token module - Suggest issues and help test

Hi folks,

I think it's about time to do another relase of both the 6.x and 5.x branches of code. The last issue I'd like to fix is menu* generally broken which has a patch that needs review.

Anything else that should really really be fixed? Add it here:

And if you're using the latest 5/6.x-1.x-dev version of token and it's working for you it would be nice to hear that as well.

3 comments

Token for the email address of the author of the comment that someone replied to

Is there a token (or a way to create one) that can be used to notify the author of the comment (not of the node) that someone has replied to it?

2 comments
laken's picture

Does module exist to let site editors maintain own tokens and replacement text?

I really love token module! I'm especially loving it in pathauto and auto nodetitles - very powerful.

Is there a module to permit site editors to create and maintain their own tokens and corresponding replacement text, either through a UI or in a text file?

The site I'm building needs to let editors store snippets of text which can be reused in many places. For instance we might have this in node content: "McDonalds has sold [num_bugers_sold] in their history". We'd need a way to edit the value for [num_bugers_sold] and have that token update wherever it's used.

16 comments · Read more
cwarden@groups.drupal.org's picture

tokens in node body

What's the proper way to replace tokens within a node body?
I've created a simple module that implements hook_token_values and
hook_token_list, but to use my token within a node body, I've had to
implement hook_nodeapi, which doesn't seem right.

<?php
function mymodule_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
   if (
$op == 'alter') {
     
$node->body = token_replace($node->body);
   }
}
?>

How about within a template? Is this discouraged?

<?= token_replace('[my-token]') ?>

Login to post comments
laken's picture

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?

6 comments · Read more
Hugo Wetterberg's picture

Token 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?

6 comments · Read more

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.

Login to post comments · Read more · 2 attachments
greggles's picture

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 more
greggles's picture

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).

Login to post comments
jredding's picture

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.

1 comment · Read more
profix898's picture

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.

Login to post comments · Read more
greggles's picture

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.

Read more
Syndicate content