You are here

function content_token_values in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 6.3 includes/content.token.inc \content_token_values()
  2. 6.2 includes/content.token.inc \content_token_values()
1 string reference to 'content_token_values'
content_init in ./content.module
Implementation of hook_init().

File

includes/content.token.inc, line 4

Code

function content_token_values($type, $object = NULL) {
  $tokens = array();
  if ($type == 'node') {
    $node = $object;
    $node->build_mode = 'token_values';
    $node->content = array();
    content_view($node);

    // The formatted values will only be known after the content has been rendered.
    drupal_render($node->content);
    content_alter($node);
    $field_types = _content_field_types();
    $type = content_types($node->type);
    foreach ($type['fields'] as $field) {
      $items = $node->{$field['field_name']};
      $function = $field_types[$field['type']]['module'] . '_token_values';
      if (!empty($items) && function_exists($function)) {
        $token_values = $function('field', $items);
        foreach ($token_values as $token => $value) {
          $tokens[$field['field_name'] . '-' . $token] = $value;
        }
      }
    }
  }
  return $tokens;
}