You are here

function theme_link_formatter_link_domain in Link 7

Formats a link using the URL's domain for it's link text.

File

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

Code

function theme_link_formatter_link_domain($vars) {

  // If no URL value is present there's no point in continuing.
  if (empty($vars['element']['url'])) {
    return '';
  }
  $link_options = $vars['element'];
  unset($link_options['title']);
  unset($link_options['url']);
  $domain = parse_url($vars['element']['display_url'], PHP_URL_HOST);
  if (!empty($vars['display']['settings']['strip_www'])) {
    $domain = str_replace('www.', '', $domain);
  }
  return l($domain, $vars['element']['url'], $link_options);
}