Iain Urquhart

{entry}

Crumbee: ExpressionEngine breadcrumbs plugin…

28 Comments

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.

Comments for this entry


Ben Lilley
2008 12 09

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


Judd Lyon
2009 02 08

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


Phil Barbato
2009 02 13

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

Thank you!


Bob
2009 03 05

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.”


Eric
2009 04 08

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


DUMB ASS SPAMMER
2009 04 08

Thanks for providing this great and useful plugins.I will let my friends to know about this for sure.

Shitty Web Site
Indian Spammer

Also, I’ll take some time to spam your site and you can screw up my links so they become irrelevant and a complete waste of time for everyone on the internets.

Thank you.


Jake Mauer
2009 04 14

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

I appreciate your efforts immensely.


Jake Mauer
2009 04 14

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!


iain
2009 04 14

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.


Jake Mauer
2009 04 14

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.


iain
2009 04 14

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.


Sam Oltz
2009 05 06

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!


Carlos Sant'Ana
2009 06 02

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


iain
2009 06 02

Hi Carlos.

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


Carlos Sant'Ana
2009 06 02

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


Jim
2009 06 23

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


iain
2009 06 23

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


Jim
2009 06 23

Thanks Iain! That did the trick.

-Jim


Ben Schaaf
2009 08 20

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.


marygladies
2009 11 04

ExpressionEngine has the most compelling set of features of any publishing system on the market.

Thanks,
Wankers


Russell
2009 11 12

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.


Sean
2009 11 18

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;


Sean
2009 11 18

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.


Jesse
2010 01 29

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!


Stuart Kirkland
2010 02 18

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?


Magnus von Bromsen
2010 04 20

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

↑ Back to top