Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

token_replace

Definition

token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array())
contributions/token/token.module, line 154

Description

Return the value of $original, with all instances of placeholder tokens replaced by their proper values. To replace mutliple types at once see token_replace_multiple().

Parameters

original A string, or an array of strings, to perform token substitutions on.

type A flag indicating the class of substitution tokens to use. If an object is passed in the second param, 'type' should contain the object's type. For example, 'node', 'comment', or 'user'. If no type is specified, only 'global' site-wide substitution tokens are built.

object Optionally, the object to use for building substitution values. A node, comment, user, etc.

leading Character(s) to prepend to the token key before searching for matches. Defaults to an open-bracket.

trailing Character(s) to append to the token key before searching for matches. Defaults to a close-bracket.

Return value

The modified version of $original, with all substitutions made.

Code

<?php
function token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array()) {
  $full = token_get_values($type, $object, FALSE, $options);
  return _token_replace_tokens($original, $full->tokens, $full->values, $leading, $trailing);
}
?>