0

How does one enable html special chars (eg. ® ) in the breadcrumb?

Apparently, the Kickstart 2 uses a custom Crumbs module and I can't figure out how to override the PHP generated as with a 'regular' Drupal theme since it doesn't use the core theme_breadcrumb() function.

2
  • Can you provide more information where you want the special char to show up? It seems this is a bit misleading, and you rather just want to know "How can I change a breadcrumb item link text", right?
    – donquixote
    Commented Aug 23, 2014 at 10:39
  • So, to clarify: You use stuff like "®" in a node title, but in the breadcrumb it shows up as "®" ?
    – donquixote
    Commented Aug 24, 2014 at 16:21

1 Answer 1

0

There are different parts to this answer.

since it doesn't use the core theme_breadcrumb() function.

By default, it does use theme('breadcrumb'). But you should have a look at the settings in admin/structure/crumbs/display.

But the check_plain() that causes special characters to be double-escaped happens in theme_crumbs_breadcrumb_link() and theme_crumbs_breadcrumb_current_page(), which you could also override.

You could also look at the $double_encode option in htmlspecialchars(), so you could use your own version of check_plain().

This being said: Simply omitting the sanitization for all breadcrumb links is a bad idea, and potentially exposes your site to script injection. If anything coming from a non-trusted source ends up in the breadcrumb, or if people add broken html into a node title or menu link title or elsewhere, this could cause broken or malicious html on your site.

I think the better option is to just use the literal character in the node title, instead of the html entity.


Some general info:

With Crumbs, every breadcrumb item title is provided by a plugin. The plugins take these from menu links, from the title / title callback of the router item, or elsewhere. In most cases there is already an existing plugin which provides the breadcrumb item title you need.

Otherwise you can write your own plugins. I can give you a hint about that, but I need more information where you want the special char to show up. (I will edit the answer then)

6
  • Please provide a hint. I need to be able to have breadcrumb strings and links like "MyTrademarkedProduct®"
    – jchwebdev
    Commented Aug 23, 2014 at 17:11
  • but which breadcrumb item should have this link text? Is this a node title?
    – donquixote
    Commented Aug 23, 2014 at 18:18
  • Yes, it's the title of a node... a Basic Page, although we will also want other content types (Commerce Products) to also have that capability.
    – jchwebdev
    Commented Aug 23, 2014 at 23:30
  • ok, so now you have the node title show up as breadcrumb text, but the html chars are not showing as expected? are they filtered out?
    – donquixote
    Commented Aug 24, 2014 at 3:45
  • I did a quick experiment with "»" in a node title on a local test site. This is escaped as "»" both on the page title display and in the breadcrumb. The title is simply meant to be sanitized, otherwise you could easily get into some injection problems.
    – donquixote
    Commented Aug 24, 2014 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.