The way it is now when the node title is added to the breadcrumb trail:

  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = $is_front ? l(t('Home'), '<front>') : l(drupal_get_title(), $_GET['q'], array('html' => TRUE,));
    }
    else {
      $breadcrumb[] = $is_front ? t('Home') : drupal_get_title();
    }
  }

...there is no way to select it in order to apply css rules to it. How about wrapping it in a span with some id or class? Like so:

  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = $is_front ? l(t('Home'), '<front>') : "<span id=\"node_title_breadcrumb\">" . l(drupal_get_title(), $_GET['q'], array('html' => TRUE,)) . "</span>";
    }
    else {
      $breadcrumb[] = $is_front ? t('Home') : "<span id=\"node_title_breadcrumb\">" . drupal_get_title() . "</span>";
    }
  }

Comments

klonos’s picture

...or better like so:

  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = $is_front ? l(t('Home'), '<front>') : "<span id=\"node_title_breadcrumb_url\">" . l(drupal_get_title(), $_GET['q'], array('html' => TRUE,)) . "</span>";
    }
    else {
      $breadcrumb[] = $is_front ? t('Home') : "<span id=\"node_title_breadcrumb\">" . drupal_get_title() . "</span>";
    }
  }

...with different ids for title and title as url, so they can be styled independently if so required.

xurizaemon’s picture

Will consider a patch, but isn't that something you'd want to do in the theme layer? (is there a specific reason this should be handled in the module?)

klonos’s picture

...but isn't that something you'd want to do in the theme layer?

Care to enlighten me? How do you mean? How would I wrap a portion of the breadcrumb in a tag with some class/id so it can be selected for css styling *after* the module has rendered the breadcrumb?

I am asking because this seemed to me the only way to go. You are right that theming is intended for the theme layer, but don't we need the "basis" of it provided by the module(?). In my solution above, I do not include any theme/style specific code. I leave this to be handled by the theme. All I am suggesting is a tag ( seemed perfect - if you think different I don't mind) and some id/class for it (again, I went with an id and called it "node_title_breadcrumb_url" for the node that is appended as url or "node_title_breadcrumb" for when appended as simple text. If one comes up with better names, again I don't mind).

klonos’s picture

Title: Allow appended title to be css selectable/themable » Allow appended title to be css selectable/themable (wrap in <span> tag + add a class or id to it)

...minor title edit to make it more obvious.

drasgardian’s picture

it would be great to be able to do this in the theming layer, but it needs this module to expose a themable function.

Something like...
Build an array of breadcrumbs with attributes (not yet html) and pass them all to a themable function
put all the calls to l() and the drupal_set_breadcrumb() inside the themable function.
Then in our template.php files we can override the themable function and add our own attributes to the l() calls.

Personally I'd like to see this so I can also truncate the size of the breadcrumb text down to about 40 characters as my site has a lot of nodes with huge titles.

dsdeiz’s picture

Hey,

Old thread but in case anyone run into these:

For #1 you can use theme_breadcrumb. Something like this:

function THEMENAME_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];

  if (!drupal_is_front_page() && variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    $title = &$breadcrumb[count($breadcrumb) - 1];
    $title = '<span id="node_title_breadcrumb">' . $title . '</span>';
  }

  if (!empty($breadcrumb)) {
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

    $output .= '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
    return $output;
  }
}

And in #5 since the breadcrumb is actually generated by drupal_get_breadcrumb, you can implement hook_menu_breadcrumb_alter like this:

function MODULENAME_menu_breadcrumb_alter(&$active_trail, &$item) {
  foreach ($active_trail as $k => $v) {
    $title = &$active_trail[$k]['title'];
    if (drupal_strlen($title) > 20) {
      $title = drupal_substr($title, 0, 20) . '...';
    }
  }
}
xurizaemon’s picture

Issue summary: View changes
Status: Active » Closed (outdated)