tokens in node body

Events happening in the community are now at Drupal community events on www.drupal.org.
cwarden@xerus.org's picture

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]') ?>

Comments

Not sure how comprehensive

patcon's picture

Not sure how comprehensive you're going, but maybe try this:
http://drupal.org/project/token_filter

Good luck, or at least hopefully this helps someone else! Cheers

Tokens

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: