a wee weblog, since 2006

Crumbee:
ExpressionEngine breadcrumbs plugin

9Dec
2008

Just written my first EE plugin, appropriately named Crumbee, its pretty crummy really.

This plugin was written when dinosaurs freely roamed the earth.
At least it feels that long ago to me…

I suggest you grab yourself a copy of Crumbly by that title attribute loving, Stephen Lewis.

It basically grabs the url of the current page and builds a breadcrumb trail from that, replacing a “-” or a “_” with a space and capitalising the words. Very handy when using the EE pages module and/you/have/long/urls.

Some notes

  • Extract, and upload the file to your system/plugin directory
  • There is an exception list you can build within the plugin to override url outputs, for example the url /about/ will result in a hyperlink “About”, you can override this to become “About Us” if you wish. An example is in the plugin.
  • To add the breadcrumbs, simply insert the following code to your template: {exp:crumbee delimiter=”›”}

    Full example would be:

    <p> You are here: <a href="/">Home</a> &rsaquo; {exp:crumbee delimiter="&rsaquo;"} {title}</p>

  • The delimiter parameter allows you to specify what html entity you would like between the links…

Released freely, use at your own risk:
Crumbee for EE1
Crumbee for EE2

Credit to sillybean.net for giving me a great start in making this plugin.

26people had something to say

  1. Ben Lilley

    Will probably make use of this at some point so cheers :)

  2. iain

    Great, hope you find it useful.

  3. Judd Lyon

    Thank you, this is quite handy, I’m using it on my blog.

  4. Phil Barbato

    Great simple plugin. This fills the gap left by the no-longer-supported Pages Crumbs plugin.

    Thank you!

  5. Bob

    This plugin is exactly what I’ve been looking for except I cannot get it to work. Only the delimiter shows up and, once in a while, the words “About Us.”

  6. Eric

    Thank you for this easy to implement plugin, wonderful, works like a champ:)

  7. Jake Mauer

    Thank you for this plugin, it’s exactly what I needed exactly when I needed it.

    I appreciate your efforts immensely.

  8. Jake Mauer

    Hi Iain,

    I’ve installed your plugin and it works great except that it inserts the delimiter before the first crumb. So it ends up being

    > Home > Segment 1 > Segment 2

    Any ideas why this could be happening?

    I’m using EE 1.6.7 and the majority of my content are built using the pages module.

    Thank you!

  9. iain

    ok, try this Jake,

    replace:

    $label = str_replace("-"," ",$label);
    $crumblabel = str_replace("_"," ",$label);
    $this->return_data .= " <a href=’/$url’>". ucwords($crumblabel) ."</a> ". $delimiter;

    with:

    if ($dir != "index.php" AND $dir != "ANY_DIR_YOU_DONT_WANT" )
    {
    $label = str_replace("-"," ",$label);
    $crumblabel = str_replace("_"," ",$label);
    $this->return_data .= " <a href=’/$url’>". ucwords($crumblabel) ."</a> ". $delimiter;
    }

    Just repeat the first line AND statement for any other directory’s you don’t want to be processed, eg:

    if ($dir != "index.php" AND $dir != "ANY_DIR_YOU_DONT_WANT" AND $dir != "SOME_OTHER_DIR" )

    make sense?

    hope this helps, sorry about the lack of code colouring/formatting here.

    Iain.

  10. Jake Mauer

    Thanks Iain, that was way faster than I expected!

    While this does work in eliminating “home” from the breadcrumbs, I actually don’t mind having it there. If I wanted to keep it as

    > Home > Segment 1 > Segment 2

    but just remove the first ‘>’ how would I go about that?

    Thanks again, I hope I’m not keeping you up.

  11. iain

    No probs Jake, its 3pm here in NZ.

    I’d just use the example in the original blog post above, the home button isn’t really going to change, and if you wanted to change the delimiter you’d have to find all occurrences of the plugin in the templates anyway…

    I normally hide the index.php with .htaccess which is why home appears for some folks using the plugin.

  12. Sam Oltz

    Iain,

    I was experiencing issues with your plugin putting two delimiters in 1st level pages. Seems that $dir sometimes comes up empty and the script still tries to put the empty variable into the bread crumbs. I seem to have fixed it by modifying your suggestion to Jake above to this:

    if ($dir != “index.php” && $dir != “”) {

    Thanks!

  13. Carlos Sant'Ana

    Thanks for your wonderful plugin.
    I installed it and it works, but in some pages I see {TITLE} in the last parameter.

    Does this only works for PAGES or also with dynamic content? I’m building an online store and wanted to include breadcrumbs to help navigation, but almost all my content is dynamic…

    Best
    Carlos

  14. iain

    Hi Carlos.

    If you want to use {title} you’ll need to place the plugin code within a {exp:weblog:entries} tag…

  15. Carlos Sant'Ana

    Thanks for your quick answer.
    Yur plugin is quite usefull…hope I can put it to work properly…
    I copy pasted your proposed code and adapted it a bit to test.

    <div class=“breadcrumb”>[url=http://www.bebesdaterra.pt]http://www.bebesdaterra.pt[/url]{exp:crumbee delimiter=”›”}{title}</div>

    In this page http://bebesdaterra.br351.com/index.php/FAQ/quais_recomendamos it renders like this…

    http://www.bebesdaterra.pt › FAQ › {title}

    Any quicktip?
    Thanks for your time…
    Carlos

  16. Jim

    Hi Iain,

    I don’t know how to install the plugin. I thought I would copy the php file to system/modules/crumbee. I made a directory for crumbee and EE CP had a problem not finding the lauguage file.
    I must be misunderstanding how to install this plugin. Any help is appreciated.

    Thanks,
    Jim

  17. iain

    Its a plugin Jim…
    Drop the file into /system/plugins/ and you’ll be good to go.

  18. Jim

    Thanks Iain! That did the trick.

    -Jim

  19. Ben Schaaf

    I noticed that special characters are not displaying correctly.

    http://sample.com/index.php/should-or-shouldn't/work/but/does/not/

    The apostrophe shows up as the encoded value..but doesn’t de-encode.

    Not sure if that makes sense.

  20. Ben Schaaf
    http://216.119.128.24/index.php/test/should-or-shouldn&#x27;t/work/but/does/not/

    my sample url got mangled in the quotes. hopefully you can figure it out.

  21. Russell

    I with you agree. In it something is. Now all became clear, I thank for the help and I hope to see more such articles.

  22. Sean

    Hello,

    I’m setting this up on a current dev site now. It works fine except that when I try to implement the hack above to remove certain directorys. Once I do that those directories disappear however now the links don’t work correctly. Instead they refresh the page and add a new bread crumb which looks something like this:

    › RASK › Events › �� ›

    please advise. Below is the exact modification I made to the plugin file.

    if ($dir != "site" && $dir != "cat" )
    {
    $label = str_replace("-"," ",$label);
    $crumblabel = str_replace("_"," ",$label);
    $this->return_data .= " <a href=’/$url’>". ucwords($crumblabel) ."</a> ". $delimiter;
    }
  23. Sean

    just posted a comment, which isn’t showing up (moderation?) anyhow I foudn the problem.

    On line 49 there are two single quotes ’ which are actually curly quotes - change them and everything works.

  24. Jesse

    Hi Iain,

    Thanks for this plugin!

    I know there is a way to override the labels from the url, but is there a way to completely ignore a specific label in the url?

    Thanks!

  25. Stuart Kirkland

    Hello Ian

    I was wondering if you could help me im trying to display segment 1 in the crumb? how do i go about doing this?

  26. Magnus von Bromsen

    Hi
    and thanks for this great plugin.

    One question: is it possible to have the last url segment shown in the breadcrum? Like this

    Url: products/cars/wheel_x

    Breadcrum: Products - Cars - Wheel X

    Best Regards,
    Magnus

As captured 12 August 2021 · The archived original