replace tokens in node body
yang_yi_cn - November 7, 2008 - 02:03
| Project: | Tokenize |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | by design |
Jump to:
Description
can we use token inside the node's body? like:
lkasjdfjaslf
asdfjaslfjlsfsfasdf
This is the [token].
askfsjflaslfs
asfsaf
Is it possible ?

#1
Actually I was trying to put a cck field as a token in the body, but
<?phpfunction hook_nodeapi(&$node, $op, $teaser) {
switch ($op) {
case 'alter':
$node->body = token_replace($node->body, 'field');
break;
?>
doesn't work.
When I use token_get_list('all'), the list shows the CCK tokens. But I have no idea how to make the replace work...
#2
CCK only provides token values when token module asks for them, so you'll need to turn to token for informations on this.
#3
The token system doesn't actually do anything on its own :)
The tokenize module theoretically does stuff like this but
1) it's not ready for 6.x yet
2) it doesn't work on node bodies, just on cck fields.
So, I'll make this into a feature request for the tokenize module to do this.
#4
Subscribing, greetings, Martijn
#5
I think that http://drupal.org/project/token_filter is the better place for this. In fact I'd be willing to deprecate the tokenize module in favor of that since it is largely abandoned now. Filters/Input formats are a much more general way to approach the problem.