You are here

function _hansel_trim in Hansel breadcrumbs 7

Same name and namespace in other branches
  1. 8 hansel.module \_hansel_trim()

Trim the title for breadcrumb links.

1 call to _hansel_trim()
hansel_get_breadcrumbs in ./hansel.module
Generate breadcrumbs.

File

./hansel.module, line 669
Hansel module

Code

function _hansel_trim($title) {
  $max_length = variable_get('hansel_max_item_length', 0);
  $word_boundary = variable_get('hansel_trim_on_word_boundary', TRUE);
  $ellpisis = variable_get('hansel_trim_ellipsis', '...');
  if (!$max_length) {

    // Trimming is disabled.
    return $title;
  }
  if (drupal_strlen($title) <= $max_length) {
    return $title;
  }
  $title = drupal_substr($title, 0, $max_length);
  if (strrpos($title, ' ') > drupal_strlen($title) / 3 && $word_boundary) {
    $title = drupal_substr($title, 0, strrpos($title, ' '));
  }
  $title = trim($title);
  return $title . $ellpisis;
}