Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
klonos...or better like so:
...with different ids for title and title as url, so they can be styled independently if so required.
Comment #2
xurizaemonWill 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?)
Comment #3
klonosCare 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).
Comment #4
klonos...minor title edit to make it more obvious.
Comment #5
drasgardian CreditAttribution: drasgardian commentedit 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.
Comment #6
dsdeiz CreditAttribution: dsdeiz commentedHey,
Old thread but in case anyone run into these:
For #1 you can use theme_breadcrumb. Something like this:
And in #5 since the breadcrumb is actually generated by drupal_get_breadcrumb, you can implement hook_menu_breadcrumb_alter like this:
Comment #7
xurizaemon