Extension talk:BreadCrumbs2

Header problem
When I enable this extension, I get an error about the headers already being sent by BreadCrumbs2.php from WebResponse.php (specifically Warning: Cannot modify header information - headers already sent by (output started at /xxxx/mediawiki-1.11.0/extensions/BreadCrumbs2.php:204) in /xxxx/mediawiki-1.11.0/includes/WebResponse.php on line 10.  Any hints as to how I might fix this? 129.21.126.84 03:32, 8 October 2007 (UTC)

Save your document (php) as plain text, not as utf encoded.


 * ok that did it, thanks 129.21.126.84 21:57, 8 October 2007 (UTC)

recharge
Well, I had the exact same problem, but the encoding was plain text: /etc/mediawiki/LocalSettings.php:              text/plain; charset=us-ascii /var/lib/mediawiki/extensions/BreadCrumbs2.php: text/plain; charset=us-ascii
 * 1) file -i /etc/mediawiki/LocalSettings.php  /var/lib/mediawiki/extensions/BreadCrumbs2.php

The real cause has to do with white spaces outside of the php start and end tags, see this link from Tech Recipes

Link crumbs to normalpages
add around line 40:

// Link crumbs to normal page, not to category page $tree[1] = preg_replace('/Category:/','',$tree[1]);

Remove Current Page Name from Breadcrumb?
Hi there. I'm loving this extension. Thank you very much! Is there any way to remove the current page name from the outputted breadcrumb? The reason I ask is because now that I have this extension every page that does not need/have a breadcrumb has the page name in place of it making it look something like this:

Main Page
Main Page Thank you! Schot 22:53, 16 November 2007 (UTC)

Response:
Try adding these lines to the MediaWiki:Breadcrumbs page and add your Main Page to a category called "Main Page":

* Main Page @ * default  @ Main Page >

It works for me! I too think this is a brilliant solution to getting breadcrumbs.

147.209.216.245 23:21, 24 January 2008 (UTC)

Number of Levels, something is wrong..
Hi, first of all: Great extension!! Please excuse so many questions, I am a dummy and I suppose the biggest is issue is that I do not get the (digital) logic behind this functions.

I am about to create an extremely structured Wiki, which implies also many levels. Eerythink is fine, but I do net get the following to work - the LeedsAccommodation line does not work at all.. * Going-to @ GoErasmus > Living Abroad > Going-to > * Living Abroad @ GoErasmus > Living Abroad > * LeedsAccommodation @ GoErasmus > UK > Leeds > Accommodation > * Leeds @ GoErasmus > United Kingdom > Leeds > * United Kingdom @ GoErasmus > United Kingdom > Page: [www.goerasmus.eu] Furthermore, I'd like to kill the UK in the LeedsAccommodation line, can I do this?? And how should I sort the lines in BreadCrumb then..

If it is a feature, it would be nice to describe on the extension page itself. My thesis is that many dummies are coming now and open a wiki… Thanks again for the great work! --Jorgusch 12:48, 12 June 2008 (UTC)
 * Btw, the solution for the Main Page does not work for me.
 * You mention above a way to link normal pages with breadcrumb–what I would like to do. How does it work then? Where does BreadCrumb know from, which line to choose? - See my 'logical question' above..

Does this (great) extension works with MW 1.13?
Its behaviour is strange, it doesn't recognize the my category "Home". 88.9.73.154 21:05, 1 August 2008 (UTC)

Breadcrumbs displaying only current page
I defined breadcrumbs for my page at Mediawiki:Breadcrumbs on my media wiki like this: * Finance @ Nlpedia > Finance >
 * Business @ Nlpedia > Finance > Business >

As a result I got breadcrumbs, but it only displays the lowest level for current page(the name of the article or category) but there's no link to the main page (or category when I'm in an article). Am I missing something here? Did I make some syntax error? Are there any additional things I should to make it work?

September 2009 -- Still getting this behavior in MW 1.13 -- anyone have this working?

January 2010 -- Doing same for me with MW 1.15.1 -- would love to see a fix to get this working, seems to be when using name > name2 > that it does not show all sub-pages if they are categories.

January 2013 -- Late reply, I had the same problem. The category actually has to exist. So go to Category:name, create the category, put in some text and then save it. You can remove the text later if you want. Hope this helps.

New Features
I made a few small modifications to the extension to allow:
 * Breadcrumbs to be placed by the template (Crumb result is passed to template via $template->data['breadcrumbs'] instead of subtitle; requires custom template to use and display). So you don't have to give up the subtitle to use the breadcrumbs extension. Access via $this->data['breadcrumbs'] in execute method of skin file.
 * MediaWiki:Breadcrumbs crumb specification to match page name (So, for example, "* Main Page @ Home" will provide a custom breadcrumb for the home page).
 * Require inclusion of the page name to be explicit in the crumb spec (using ), so it can be left out if you want to.

Modified lines (x3) are marked with **** function buildBreadcrumbs( $skin, $template ) { # Get the list of categories for the current page preg_match_all( '`title="Category:(.*?)"`', $skin->getCategories, $matches, PREG_PATTERN_ORDER ); $categories = $matches[1]; # Treat the namespace as a category too if ( $skin->mTitle->getNsText ) $categories[] = $skin->mTitle->getNsText; # ****: Treat the page name as a category too $categories[] = $skin->mTitle->getText; # Load and parse the breadcrumb template. If it's a redirected page, extract redirect info $crumbs = matchFirstCategory( CRUMBPAGE, $categories ); $breadcrumb = trim( $crumbs[0] ); # ****: Require page name to be explicitly set if ( preg_match('/\(Redirected.*?\)/', $template->data['subtitle'], $match) ) $breadcrumb .= ' '. $match[0]; # Set the page subtitle to the breadcrumb contents $template->set( 'breadcrumbs', $breadcrumb ); # ****: Store in breadcrumbs data object.

Debug Info?
I am having problems getting this extension to work with MW1.15. All indications seem to point to the extension working but I do not get the rewriting of the subtitle as I would expect it to. Is there any way to debug the extension to see if it is working correctly? I am afraid that it might not be able to call the hook to rewrite the subtitle, perhaps due to something in my setup.

I believe I am doing everything correctly:
 * Writing the breadcrumbs into MediaWiki:Breadcrumbs
 * Category tags on the pages that I want to apply the breadcrumbs to
 * All PHP scripts have permission 755
 * Special:Version shows that version 0.9 of the extension is installed

However the subtitle will not change on the pages no matter what.

Any suggestions?

''Edit: Okay, that was silly. I just noticed that if the category page is not saved, then it won't work. Silly mistake. Anyway, just leaving this up in case other people have similar trouble. Just save the category page with placeholder text.''

Doesnt seem to work in 1.16
Iam only getting the current pagename in the breadcrumb field. Tried a lots of configurations but no luck.

I went to see if the extension works properly in other wikis. This one has version 1.16.0 and Breadcrumbs2 seems to works quite well. This one has version 1.15.5 and it works well too. In contrast to that this one has version 1.11 and it seems to be broken. So it seems the bug has nothing to do with the mediawiki version.. Does anyone have a clue? Any help will be highly appreciated. Stefahn 2103, 6 January 2011 (UTC):
 * I have the same problem on my two wikis (versions 1.15.5 and 1.16.0).


 * I have also a problem using Version 1.16. I get Breadcrumbs displayed without the Breadcrumbs2-Extension. Perhaps because I have smwhalo installed. But the breadcrumbs work in a "How did I get here"-sence and not in the expected "Where am I"-sence. I added this line to MediaWiki:BreadCrumbs:


 * Best-Pratice@ Hauptseite > Best-Pratice >
 * When I deactivate SMWHalo I get only the page title displayed. I think that the Breadcrumbs-Feature of smwhalo and the Breadcrumbs2-Extension hinder each other. stevewilson, 19 December 2011 (UTC):


 * Meanwhile I could solve the problem. I didn't notice that you have to adapt the code if you're using another language than English. See here. I adapted the code and now it works like a charm (see here for example). Stefahn 19:57, 23 January 2012 (UTC)

Autogenerate Mediawiki:Breadcrumbs Category List
Has anyone got a successful implementation of using the code from the Mediawiki Breadcrumbs extension to automatically generate the list of categories?

I've got a simple, structured category hierarchy and it's a bit of a pain to have to re-enter the information manually, when the category tree could be automatically worked out.

Problem with 1.18
Just tried to run my wiki with 1.18, fails on: Call to a member function getNsText on a non-object line 51. More details as I figure them out.--Olivier Beaton 20:02, 29 November 2011 (UTC)

Fix problem with 1.18
Simply replace code "->mTitle->" by "->getTitle->". --Nda 19:22, 08 Januar 2012 (Moscow time)

code injection problem
Is due to the preg_replace use of the "/e" extension.

Any thoughts on how to correct this?

Code injection fixed
I have fixed the code injection and a few other errors when running this extension against the latest version of MediaWiki (currently under pending changes). I used preg_replace_callback instead of preg_replace with /e modifier to bypass any code injection. I also changed $skin->mTitle to $skin->getTitle and checked the state of $wgParser->mOutput before calls to $wgParser->disableCache.


 * Hello, could you please post the exact changes you made? I would love to use this extension and make it more safe. Thanks in advance! --77.2.156.93 17:17, 11 June 2012 (UTC)

Extension no longer works with mediawiki 1.23
I am using Mediawiki 1.23alpha (9e03598), and the extension does not work. Instead of breadcrumbs, it only displays the title of the page (non-linked).

Conversely, the classic BreadCrumbs extension still works just fine.

Please update the extension to work with the newest version of mediawiki. — Preceding unsigned comment added by 27.124.100.29 (talk • contribs) 01:09, 19 January 2014
 * I confirmed that it is working with 1.23. Please make sure that you followed the usage instructions. --Ike @ WikiWorks 22:37, 23 June 2014 (UTC)
 * I'm having the exact same problem in 1.23. I'm following the usage instructions perfectly. Any assistance would be great. — Preceding unsigned comment added by 98.225.11.166‎ (talk • contribs) 16:55, 23 August 2014‎
 * If you are having trouble with the extension, please post a live example. Please also see if the [ old version of the extension] works for you. --Ike @ WikiWorks 00:32, 25 August 2014 (UTC)

Breadcrumb data page?
I don't fully understand what I'm supposed to do with the breadcrumb data page. Am I editing the Mediawiki breadcrumb page, or the breadcrumb page on my own wiki? I'm not finding the breadcrumb page at either Mediawiki, or my own page. I've installed the extension, and created hiarchy categories, but I'm only seeing the current page displayed at the top, not any breadcrumbs. Any help on where to go from here would be appreciated. — Preceding unsigned comment added by 50.97.49.97 (talk • contribs) 18:29, 28 January 2015
 * You need to create a page titled "MediaWiki:Breadcrumbs" in your own local wiki. I clarified this a bit in the documentation. Then follow the instructions in the Usage section. --Ike @ WikiWorks 23:36, 28 January 2015 (UTC)

BreadCrumb2 work with namespaces but not with categories
Hi, I am able to show up breadcrumb if I use namespaces (e.g. default, category), but when I use category name instead of namespace, breadcrumb doesn't show up; any idea if I am doing something wrong. My code when using categories is: Thanks, Muhammed.nauman (talk) 11:34, 22 April 2015 (UTC)
 * It looks like that should work. My only guess is to try without the underscores. If that doesn't work, a live example would be easiest for debugging. --Ike @ WikiWorks 16:50, 22 April 2015 (UTC)

Thanks Ike, It worked when I tried without the underscores

Comparison with sub-pages
Can anyone explain the difference between this extension and sub-pages?

How to change BreadCrumb font size and background color
Hi,

I'd appreciate any guidance on changing the BreadCrumb font size and background color

Thanks, Nauman

BadTitle
When I am on an unknown page or the front page the breadcrumbs says "Badtitle". Is there any way I can change Badtitle to something else?

Previous Page Visited?
Is it possible to have a previous page that follows you in the breadcrumbs?


 * This is done with Extension:BreadCrumbs, a different extension. --Ciencia Al Poder (talk) 22:39, 8 February 2018 (UTC)

How to get Last Page
Is there a way to display the last visited page in the breadcrumbs?


 * This is done with Extension:BreadCrumbs, a different extension. --Ciencia Al Poder (talk) 22:40, 8 February 2018 (UTC)

Remove breadcrumb
I have a situation where I have defined the category pattern for the parent article to show the navigation. On the child pages, there it is still showing up using the page title, as in the image.

Could not upload into MediaWiki so follow link to see. 

Question Is there a way to turn off the extension for pages that do not meet the defined category pattern?

Goldbishop (talk) 02:27, 14 February 2018 (UTC)

RESPONSE:

Yes. Unfortunately it's not documented on the extension page.

The extension code reflects the existence of the following variable:.

Change its value by inserting the following in LocalSettings.php:.

--74.196.230.108 23:23, 4 March 2019 (UTC)

I can't grasp this
I really don't know what I'm doing, so please explain like I'm 5.

How does adding the breadcrumbs actually work? I'm able to get the homepage set, but i'm not sure how to get further than that.

What is the point of adding each line?

I can't grasp this either
Shouldn't the breadcrumbs be automatic, without adding any line (à la DokuWiki)?

I simply can't seem to understand how to make this extension work… is of no help either. :-(

FIX for Issue: Does not work, only displays current page with no actual crumbs
See corrected fix below: Fix for "Displays page title only - No Breadcrumbs" in PHP 7.x

I couldnt get this to work for the life of me, but I finally got it working. I think its due to php.ini and how constants are handles, but I fixed it in the code since I didnt want to touch my php setup.

Issue: Didnt work. Only displayed current page with no actual crumbs

-Problem: Constants DELIM & CRUMBPAGE arent passing their actual value, rather the variable name. So it cant ever find the page, or get its content from MediaWiki:Breadcrumbs Fix: \wiki\extensions\BreadCrumbs2\BreadCrumbs2.class.php Search/Replace: "CRUMBPAGE" with "MediaWiki:Breadcrumbs" Search/Replace: "DELIM" with "@" //$crumbs = $this->matchFirstCategory( CRUMBPAGE, $categories ); $crumbs = $this->matchFirstCategory( 'MediaWiki:Breadcrumbs', $categories ); //$crumbs = $this->matchFirstCategory( CRUMBPAGE, $categories ); $crumbs = $this->matchFirstCategory( 'MediaWiki:Breadcrumbs', $categories ); //$pos = strpos( $nav, DELIM ); // End of category $pos = strpos( $nav, "@"); // End of category //return $this->normalizeParameters( $breadcrumb, DELIM, 3 ); return $this->normalizeParameters( $breadcrumb, "@", 3 );

Implementation Example via Category
(After you installed it)

MediaWiki:Breadcrumbs page: * Plumbing @ Home > Construction > Plumbing >

Any page, add this line:

Fix for "Displays page title only - No Breadcrumbs" in PHP 7.x
16 Jan 2019

Seems like the Class definition needs to change the syntax of how it references the constants once they are done. I replaced all instances of "DELIM" and "CRUMBPAGE" with "self::DELIM" and "self::CRUMBPAGE" in BreadCrumbs2.class.php and it works now. (Don't replace the original constant definitions in the beginning, of course.)

(Confirmed working with PHP 7.3.13 and MediaWiki 1.33)


 * Patch 598685 committed. Raymond (talk) 08:56, 26 May 2020 (UTC)