can we use token inside the node's body? like:

lkasjdfjaslf
asdfjaslfjlsfsfasdf
This is the [token].
askfsjflaslfs
asfsaf

Is it possible ?

Comments

yang_yi_cn’s picture

Title: tokens in node body » cck token replace in node body not working?
Project: Token » Content Construction Kit (CCK)
Version: 6.x-1.11 » 6.x-2.1

Actually I was trying to put a cck field as a token in the body, but

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

yched’s picture

Project: Content Construction Kit (CCK) » Token
Version: 6.x-2.1 » 6.x-1.11
Component: Documentation » Miscellaneous

CCK only provides token values when token module asks for them, so you'll need to turn to token for informations on this.

greggles’s picture

Title: cck token replace in node body not working? » replace tokens in node body
Project: Token » Tokenize
Version: 6.x-1.11 » 5.x-1.x-dev
Component: Miscellaneous » Code
Category: support » feature

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.

summit’s picture

Subscribing, greetings, Martijn

greggles’s picture

Status: Active » Closed (works as designed)

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.