You are here

function nodereference_token_values in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 modules/nodereference/nodereference.token.inc \nodereference_token_values()

Implementation of hook_token_values().

File

modules/nodereference/nodereference.token.inc, line 29
Provides tokens for nodereference fields.

Code

function nodereference_token_values($type, $object = NULL, $options = array()) {
  if ($type == 'field') {
    $item = $object[0];
    $title = is_numeric($item['nid']) ? _nodereference_titles($item['nid']) : '';
    $tokens['nid'] = $item['nid'];
    $tokens['title'] = $title ? check_plain($title) : '';
    $tokens['title-raw'] = $title;
    $tokens['link'] = isset($item['view']) ? $item['view'] : '';
    $tokens['path'] = is_numeric($item['nid']) ? url('node/' . $item['nid']) : '';
    $tokens['url'] = is_numeric($item['nid']) ? url('node/' . $item['nid'], array(
      'absolute' => TRUE,
    )) : '';
    return $tokens;
  }
}