You are here

function _link_field_formatter_title in Link 5

Helper function for link_field_formatter().

1 call to _link_field_formatter_title()
link_field_formatter in ./link.module
Implementation of hook_field_formatter().

File

./link.module, line 701
Defines simple link field types.

Code

function _link_field_formatter_title(&$field, &$item, &$node) {

  // Use the title defined at the field level.
  if ($field['title'] == 'value' && trim($field['title_value'])) {
    $title = $field['title_value'];
  }
  else {
    $title = $item['title'];
  }

  // Replace tokens.
  $item['html'] = FALSE;
  if (module_exists('token') && ($field['title'] == 'value' || $field['enable_tokens'])) {

    // Load the node if necessary for nodes in views.
    $token_node = isset($node->nid) ? node_load($node->nid) : $node;
    $title = filter_xss(token_replace($title, 'node', $token_node), array(
      'b',
      'br',
      'code',
      'em',
      'i',
      'img',
      'span',
      'strong',
      'sub',
      'sup',
      'tt',
      'u',
    ));
    $item['html'] = TRUE;
  }
  return $title;
}