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
Description

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

lkasjdfjaslf
asdfjaslfjlsfsfasdf
This is the [token].
askfsjflaslfs
asfsaf

Is it possible ?

#1

yang_yi_cn - November 12, 2008 - 19:02
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

<?php
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...

#2

yched - November 12, 2008 - 19:06
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.

#3

greggles - November 17, 2008 - 16:40
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 request» feature request

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

Summit - November 26, 2008 - 09:20

Subscribing, greetings, Martijn

#5

greggles - December 23, 2008 - 15:21
Status:active» by design

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.

 
 

Drupal is a registered trademark of Dries Buytaert.