You are here

function token_field_parse_as_php in Token Field 6

This function is used to parse a token_field tempalte as PHP before parsing the tokens. It allows site builders to use basic PHP checking to control the token output (such as controlling 'lists' of delimited tokens).

The Body is taken by reference, so the function does not return any value, instead altering the $body directly.

The rest of the parameters are provided by the token_field_field() function and the delta refers to the specific item within $items that is being processed.

The intention of using this function is that is "sandboxes" the eval() call which helps to avoid items such as $node being altered directly.

1 call to token_field_parse_as_php()
token_field_field in ./token_field.module
Implementation of hook_field().

File

./token_field.module, line 215
Optional extension to CCK (Content Construction Kit) to provide a read-only field which allows embedding of "compound" fields using Tokens.

Code

function token_field_parse_as_php(&$body, $node, $field, $items, $teaser, $page, $delta) {
  ob_start();
  print eval('?>' . $body);
  $body = ob_get_contents();
  ob_end_clean();
}