Posted by cwarden@xerus.org on May 29, 2008 at 11:27pm
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
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