We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New 'Breadcrumb' plugin available.

Development and Programming

xmaker's avatar
xmaker
6 posts
19 years ago
xmaker's avatar xmaker

Ok, thanks… i have 130 categories please give me example, that I should make?

       
davidmok's avatar
davidmok
1 posts
18 years ago
davidmok's avatar davidmok

Thank you MF for a nice and nifty plugin.

In case anyone is interested, I have made a slight modification to MF’s plugin to support getting the ancestor categories (ie. the breadcrumbs) using category names instead of category IDs. This might be useful for those who prefer to use category names in their URLs rather than IDs.

This does assume that to operate correctly, you use unique category names in your categories within EE (however, if you are using names in the URLs, then you probably already have enforced unique names in your categories anyway).

e.g. usage of the modified version of the plugin would be:

Category >{exp:replace find="_" replace="SPACE"}{exp:breadcrumb root_node_name="{segment_3}”} {category_name} >{/exp:breadcrumb} {segment_3}{/exp:replace}

In this example, what’s going on is:

1) the category name (root_node_name in the parameter list to be consistent with naming of params that MF used) comes from “segment_3” of the URL. adjust this to whatever is suitable for how your site is set up

2) “best practice” is not to have spaces in your URLs, so we set up all our category names with “_” for spaces. So in the above, we are replacing the underscores with spaces before displaying the text to users. This requires you to install the “Find and Replace” plugin from Lodewijk Schutte, which you can find elsewhere on the forums.

3) The breadcrumbs are formatted to give a final display like this “Category > Parent > First Child > Second Child > Third Child > etc…”

As far as I know, the modifications have not broken any of the original functionality of the plugin. That said, the modifications are not the most robust possible and do assume that you will put in valid text into the root_node_name param. If you put in some invalid text, you may get unexpected results. For us, we have found the modified version to work well enough to use in production without any issues.

Hope this is of use to some of you.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

I have removed your plugin as MF’s is under copyright and I didn’t see mention in here that you had permission to modify it. Please contact him with any changes you might have made. Thank you =)

       
Kevin Evans's avatar
Kevin Evans
222 posts
18 years ago
Kevin Evans's avatar Kevin Evans

I cant get this to work, nothing shows when I have this:

{exp:breadcrumb root_node="10" sort_direction="desc"}
<li>{category_name}</li>
{/exp:breadcrumb}

10 is my category id for my paintings category…And I have renamed the plugin to pi.breadcrumb.php

Im on EE 1.5.2. Is it compatible with the plugin?

thanks!

       
Kevin Evans's avatar
Kevin Evans
222 posts
18 years ago
Kevin Evans's avatar Kevin Evans

here’s the address http://www.kevinevans.net/art/category/C10/

       
Brent Cartier's avatar
Brent Cartier
87 posts
17 years ago
Brent Cartier's avatar Brent Cartier

EDIT: It turns out it was easy to modify the plugin…. thanks anyway!

Is there a way to use this plugin with url titles for categories turned on? I’d rather use the cat url titles that C16 for example…

If not, would it be easy to extend the plugin to do that?

Thanks!

       
iain's avatar
iain
317 posts
17 years ago
iain's avatar iain

Ok you might laugh at myt ott code, but I’m just stoked i got unlimited menu heirarchy of pages, nav highlighting and breadcrumbs from a signle template without using the pages module! Only this plugin was required and the 1.6EE…

Prerequirements are:

1) the breadcrumb plugin 2) ‘Use Category URL Titles In Links?’ set to yes, (note in the example below i’ve used section as my ‘category url indicator’) 3) You’ll also need to allow php on your template. 4) A weblog called Pages 5) A category group that relates to your site structure 6) Auto select category parents should be off 7) A single entry into each of your pages categories (page content)

Screenshot of the output attached.

Heres my nasty code that someones bound to improve on:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>

{!-- Nav Highlighting --}
<style type="text/css">
<!--
li a.{segment_2} {color: red;}
-->
</style>
</head>
<body>

{!-- Query to establish current node for breadcrumb plugin --}
{exp:query sql="SELECT cat_url_title AS caturltitle, cat_id, cat_name FROM exp_categories WHERE cat_url_title = '{segment_2}' "}

{!-- Begin Breadcrumbs --}
<a href="http://{path=/}">Home</a> > 

{exp:breadcrumb  root_node="{cat_id}"}

{!-- Open the link and begin the hack --}
<a href="http://10.1.1.3/ee1-6/index.php/section/{%21--">{!-- Close the link --}__{category_name}__</a> > {/exp:breadcrumb} 
{/exp:query}


{exp:weblog:entries limit="1" weblog="pages"}
{title}
{!-- End Breadcrumbs --}

{!-- Content--}
<h1>{title}</h1>
{content}
{/exp:weblog:entries}

{!-- Menu--}
{exp:weblog:categories weblog="pages" show_empty="no"}<a href="http://{path=/}" class="{category_url_title}">{category_name}</a>{/exp:weblog:categories}


</body>
</html>
       
EYEWEAVER's avatar
EYEWEAVER
59 posts
17 years ago
EYEWEAVER's avatar EYEWEAVER

hmmm it seems that the plugin is not working after all :(

       
Ivan Thomas's avatar
Ivan Thomas
19 posts
17 years ago
Ivan Thomas's avatar Ivan Thomas

Hi all,

I’ve a problem with MF’s subcategories plugin.

{exp:subcategories root_node="{embed:category}" sort_by="custom_order"}
     <li><a href="http://{path=products/list}">{category_name}</a></li>   
{/exp:subcategories}

This code list subcategories correctly, but my problem is with links. Because isn’t like categories tag, with this code, the dynamic path won’t work.. and every link goes to products/list.

¿How can fix it to take dynamic url, like categories tag?

Thanks all,

       
Bruce2005's avatar
Bruce2005
536 posts
17 years ago
Bruce2005's avatar Bruce2005

Does this plugin work? I’m using it with 1.6.3, and get nothing showing at all. Added root node. changed to php, using the second fixed version, using cat id. zip…

       
Chad Crowell's avatar
Chad Crowell
242 posts
17 years ago
Chad Crowell's avatar Chad Crowell

Working fine with 1.6.3 here, and modded to use category titles, which works as well.

       
Murmann's avatar
Murmann
36 posts
16 years ago
Murmann's avatar Murmann

MF, I have trouble with your plugin: See my post.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Peter, you didn’t post what the problem is in this thread.

       
Murmann's avatar
Murmann
36 posts
16 years ago
Murmann's avatar Murmann

Ok: I am posting what I posted in the How To section Sue Crocker pulled code for me to sort selectively display categories and display them in the right column. There is a bug in it when I limit the number of entries displayed let’s say to 5 and then the blog paginates. when you click on the second page of entries the category sorter does not work.

Here is when it works fine without page pagination (although when logged it as admin I get this error: Notice: Undefined variable: cat_name in /home/pmh2640/public_html/murmann/system/core/core.functions.php(637) : eval()‘d code on line 117)

http://professor-murmann.info/index.php/weblog/courses/

Here is a copy with the big bug. I already put in on the second page of entries so that you can see it readily. http://professor-murmann.info/index.php/weblog/courses_bug/P5/

This is the code that Sue installed. She says it is from someone called MF in Germany. Can you help?

**********Code*******************************



						
       
vosSavant's avatar
vosSavant
380 posts
about 15 years ago
vosSavant's avatar vosSavant

There are a some posts in this thread from people saying the plugin doesn’t work, but I managed to get it working fine in EE 1.6.9 build 20100430. I’m adding to this thread to show people how to add category URL functionality, since this plugin does not natively support it.

First of all, the plugin does not seem to work inside of the category heading tag pair, so I had to move the plugin code to an embed template and pass in the category ID:

Main template:

{exp:weblog:category_heading weblog="products"}
   {embed="embeds/breadcrumb" cat_id='{category_id}'}
   {category_name}
{/exp:weblog:category_heading}

Embedded breadcrumb template:

{exp:breadcrumb root_node="{embed:cat_id}"}
   {category_name} ›  
{/exp:breadcrumb}

This created a nice breadcrumb trail, but none of the ancestor categories were linked. To do this, I had to make an adjustment and an addition to the plugin file:

Tell the plugin to grab URL info (around line 218):

$sql = "SELECT cat_id, ***cat_url_title***, parent_id, cat_name, cat_image, cat_description, cat_order FROM exp_categories WHERE cat_id = ...

The cat_url_title piece (surrounded by asterisks) is not there; I added it so the query grabs the URL for each category.

Next, add a new variable (copy + paste the following somewhere near line 232):

//parse category_url_title variable
if ($key == 'category_url') {
   if (isset($query->row['cat_url_title'])) {
      $tagdata = $TMPL->swap_var_single($val, $query->row['cat_url_title'], $tagdata);
   }
}

Lastly, in your embed template, add a link with the new {category_url} variable, and you’re in business:

{exp:breadcrumb root_node="{embed:cat_id}"}
   <a href="http://{site_url}category/{category_url}">{category_name}</a>  ›  
{/exp:breadcrumb}

Thanks to MF for this really helpful plugin. I looked everywhere and this is THE best way to do category breadcrumbs.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.