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.
I understand that token.module is fully capable of this - just need to know whether a simple module exists for maintaining one's own arbitrary tokens and replacement text.

Comments
TNT!
http://drupal.org/project/tokennodetokens
It's dy-no-mite.
Note that it's unsupported - if you use it and like it, perhaps you could take over for Jacob.
--
Open Prediction Markets | Drupal Dashboard
knaddison blog | Morris Animal Foundation
Shades of Jimmy Walker
Shades of Jimmy Walker :-)
Thanks greggles, I found that after I posted. It's an interesting approach, just using a node type to store the token/text pairs. So that takes care of the storage angle.
Next step is to actually token-enable the body fields of the content types I want to use these in. Tokenize seemed like just the thing, but, alas, I am getting this error persistently:
http://drupal.org/node/164464#comment-801288
and haven't been able to debug it after a couple of hours. This module seems to be unsupported as well.
Any tips? Is there another way to make token.module parse the fields I need? I had hoped this would be simpler, but am willing to persevere! And I will consider taking over TNT - it would be my first maintained module on d.o.
Did you check out reptag?
Reptag maybe - it uses tokens too but also allows you to easily define your own "tags" on a site-wide or per-user basis - that might be a better way of solving the original issue.
http://drupal.org/project/reptag
Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.
I installed reptag and...
Really appreciate the suggestion - I recall I tried this out a few years ago...
I just installed reptag and it looks like just what I need, but I have quickly run into a problem - doesn't seem to work with Contemplate module. Documented here: http://drupal.org/node/258441 and here: http://drupal.org/node/272959
I'm also not crazy about using something that has a back-end so redundant with Token, but it looks like there's a history there.
The reptags UI is just what I need, so if I can resolve the Contemplate issue, I'll be all set. Any pointers?
Disable some "reptag modules"?
I've not come across that problem (installed Contemplate but not actually used it so far.)
Try disabling the reptag modules that you don't need - that's in the admin screen somewhere - maybe the incompatibility is from one particular module. I have found, for example, that the STF module has an annoying habit of wrapping things in unnecessary
<p>tags, which can be a problem in some situations. In any case, disabling the unused ones can only improve performance.Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.
tokenize maintainership
Since the module seems somewhat unloved I've offered to co-maintain (or maintain) the module. If we don't hear back in two weeks then I'll switch it over to me. Until then, it's time to work on patches to get it closer to working shape.
Regarding reptags, my discussions in irc with profix898 to discuss and potentially integrate it weren't very fruitful - neither he nor I have the time to do that (nor any other token maintainer). At this point, it's pretty clear that Token module is the more popular for other modules to integrate with. However, it also appears to be less sophisticated than reptags :/
--
Open Prediction Markets | Drupal Dashboard
knaddison blog | Morris Animal Foundation
For my part a simple UI for
For my part a simple UI for dumb users to define their own tags would help a lot. Having tags (or "tokens") per user could be nice too, though so far I've not needed them.
Defining tokens in a node would be ok, but maybe just one node to hold a list of all tokens, otherwise it a bit of a performance issue obviously.
My own need right now is as a module developer, that's why I was looking at this thread in the first place - looking for background info, trying to decide whether to use tokens or reptags (or both, or neither!) But I definitely need a UI for the user to define tokens/tags, so unless I include that in my module (not really the right place for it!) I can't use Tokens. The Reptags UI is not flash but functional - does some AJAX stuff to speed things up. Some scrolling lists would be nice, otherwise with a lot of tags you end up with a huge page.
Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.
simpler UI for TNT
You could create a super simple AJAX UI for TNT if you used Views and Edit View I may just have to make a screencast of how to do this because it is really cool.
People talk a lot about the performance problems around nodes - but if you don't go crazy at the contrib module buffet then I don't think it's really a big deal. I have yet to see some real numbers comparing a node-based storage system to a simple database table storage system.
--
Open Prediction Markets | Drupal Dashboard
knaddison blog | Morris Animal Foundation
Yes please!
The screencast would be great - I've been meaning to investigate Edit View for ages.
Agreed with what you say about nodes and database performance in general, and for relatively complex data structures the node approach seems sensible. But it really would seem bad design to me to have one node per token. Maybe what's needed is some kind of "fast node" which is used only for simple data types and bypasses most of the usual processing that's done for nodes. Hmmm.... I might even try creating such a thing!
Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.
Perhaps you can shed some
Perhaps you can shed some light on what Tokenizer actually does - I'm not clear. I'm clear that TNT is a simple module that defines a "token" node type with "token" and "replacement text" as fields, and then exposes these via the token API. So you could say that TNT is a "producer" of tokens, but am I right in thinking that is not enough to let you use the tokens in node text, i.e. that you must also have code to be a consumer of tokens? I was going on the hunch that you also needed something like Tokenize to handle the processing of submitted CCK nodes and run the replacements. Is that its purpose?
Regarding reptags, it has a well-thought-out UI with granular selection of which fields to enable for which content types, nice permission system, caching, seems to be well-coded (this to my beginner's eyes.) It would be great to its front-end with Token's back-end (though I understand the author's point that it has some advanced processing that token lacks.) If my skills improve enough to allow it, I might try my hand at a patch...
indeedy do
You've perfectly described how Token module, TNT, and Tokenize work together.
knaddison blog | Morris Animal Foundation
Have more than one reptags/token-replacement in a node (templat?
Hi,
Thanks for these great modules. As described above I would like to use exactly this functionality, but enhanced with the following.
I would like to be able to set different replacement text depending on a token-node in relation to the taxonomy term on which the node is attached to.
So may be more nodes than one, related to attached amount of taxonomy terms.
Will this be possible with this line of modules? (token, tokenize, node token and replacement tags)?
In general I would like to have a template as the following:
This course is given in the [replacement-tag1] faculty. This [replacement-tag1] faculty is especially good in [replacement-tag2]Then I would like to have a table with
[replacement-tag1] : economics, mathematics, lyrics
[replacement-tag2]: social economics, arabic math
then the possibility to say have a combination of the both: economics - social economics, mathematics, arabic math.
then the content would be shown in different nodes with possibility to change the node-title, metatags etc..
So in the end the combination of text, with replacement-tags will show a instance of a template.
It would be great if the possibility would be there to have more than one template as a node, then a table of combinations for replacement-tags, attach possibility to a template node, and usage of taxonomy terms to have the filled in nodes attached to views/panels etc..
Hopefully you understand the idea, and I think this will be a great idea of template building with unique content attached to a template with text!
Thanks a lot in advance for going into this deeper!
greetings,
Martijn
Maybe you can already with reptags?
ISTR reptags can take "parameters" - I haven't tried it - maybe that would do what you need.
Another possible solution in the longer term -- I am working on front-ending reptags and/or tokens with some pre-processing, primarily aimed at handling multiple languages. This is so that you can put something like: #ASK_FOR_NAME somewhere and it will display as "Your name, please:" when the user has English set, and "Tu nombre, por favor:" when the user has Spanish set. Yes, I know this is already feasible via the standard translation system, but I have my reasons!
So, the tag/token will be expanded to something different depending on the currently selected language - I'm building it in such a way that other factors (not just language) could be used to determine which "translation" is used for the tag. So, I'll bear in mind what you need to do - maybe (quite possibly) I'll be able to include that functionality.
Currently part of the team at https://lastcallmedia.com in a senior Drupal specialist role.
depending on different things than language..
Hi Netgenius,
It would be great to have the expantion also take taxonomy terms in consideration next to languages. So that a node with a reptag inside of it can be outputtet based on the taxonomy terms which the node is attached to!
So when taxonomy terms are economics and social economics, that way the node will be filled with the information in those token/reptag instances..
Great you are working on something like this!
I do not want to hijack this threat, please if somebody things this I will start a new thread about this subject.
Greetings,
Martijn
I was ask to comment here ;)
You should try the 6.x-1.x-dev version of reptag. I spent some time to improve the tags admistration and to make it more convenient (especially if you use multi-lingual replacement tags). It does have a pager now and some more AJAX goodness for improved workflow.
Its not that I wrote reptag to create an improved token module. Reptag was available long before token was even written. From my point of view the reason why token is far more popular is that it was written by a well-known developer, who promoted it successfully in the developer community (not sure he did know about reptag at that time at all).
There is a fundamental difference between reptag and token. Reptag uses regular expressions to handle replacements whereas token uses str_replace().
It would be great if reptags
It would be great if reptags could have more than one instance of a replacement (depending on may be taxonomy term usage or something else), which makes it possible to have a parent-node as template and other nodes filled with the values from the different reptags instances, like automatic node building (based on: http://mediumexposure.com/techblog/how-build-node-drupal-programmatically):
<?php
$newnode = new stdClass();
$newnode->title = 'Faculty';
$newnode->body = 'This is the [reptags-1] page for this faculty. We specialize in [reptags-2]';
global $user;
$newnode->uid = $user->uid;
$newnode->type = 'page';
$newnode->status = 1;
$newnode->promote = 0;
node_save($newnode);
?>
Reptags and token are great modules I think! with lots more potential together and alone!.
Greetings, Martijn