On my installation, this extension breaks the whole site. I have not investigated any further because I do not really need the functionality.
Extension talk:BreadCrumbs/Archive 2
Appearance
Hi there,
I'm noticing that certain config options are working correctly, but others are not. In my LocalSettings.php, I have changed configs like the following:
$wgDefaultUserOptions['breadcrumbs-delimiter'] = '––>'; $wgBreadCrumbsShowAnons = false;
$wgBreadCrumbsIgnoreNameSpaces = array("Special:AllPages"); $wgDefaultUserOptions['breadcrumbs-numberofcrumbs'] = 2;
The first two have taken effect and work. The second two do not work.
Is this the correct way of adding these configs to my LocalSettings?
Any help would be much appreciated.
Sorry, some formatting issues. Question should read as below:
Hi there,
I'm noticing that certain config options are working correctly, but others are not. In my LocalSettings.php, I have changed configs like the following:
$wgDefaultUserOptions['breadcrumbs-delimiter'] = '––>';
$wgBreadCrumbsShowAnons = false;
$wgBreadCrumbsIgnoreNameSpaces = array("Special:AllPages");
$wgDefaultUserOptions['breadcrumbs-numberofcrumbs'] = 2;
The first two have taken effect and work. The second two do not work.
Is this the correct way of adding these configs to my LocalSettings?
Any help would be much appreciated.
Hi there, how did you arrive at the decision to try $wgBreadCrumbsIgnoreNameSpaces = array("Special:AllPages")
?
I too would like to ignore Special pages, but cant seem to figure out how.
I have updated my local copy of the extension code to use the newer extension loading mechanism in MW 1.25+. This has involved creating an extension.json file and changing the hooks file to be a class. This code is probably useful to others, but I do not have or want repository access so it is reproduced below. Sorry for the long message.
Ben
BreadCrumbsFunctions.php
Obsolete. Can be deleted.
BreadCrumbs.php
Obsolete. Can be deleted.
new LocalSettings.php contents:
wfLoadExtension( 'BreadCrumbs' );
$wgBreadCrumbsDelimiter = ' > ';
$wgBreadCrumbsCount = 5;
$wgBreadCrumbsShowAnons = true;
new file - extension.json
{
"name": "BreadCrumbs",
"author": "Manuel Schneider",
"url": "http://www.mediawiki.org/wiki/Extension:BreadCrumbs",
"descriptionmsg": "breadcrumbs-desc",
"type": "parserhook",
"ExtensionMessagesFiles": {
"Breadcrumbs": "BreadCrumbs.i18n.php"
},
"ResourceModules": {
"ext.breadCrumbs": {
"styles": "BreadCrumbs.css"
}
},
"ResourceFileModulePaths": {
"localBasePath": "",
"remoteExtPath": "BreadCrumbs"
},
"Hooks": {
"ArticleViewHeader": [
"BreadCrumbsHooks::fnBreadCrumbsShowHook"
],
"OutputPageParserOutput": [
"BreadCrumbsHooks::fnBreadCrumbsOutputHook"
]
},
"AutoloadClasses": {
"BreadCrumbsHooks": "BreadCrumbs.hooks.php"
}
}
new file - BreadCrumbs.hooks.php
class BreadCrumbsHooks {
public static function fnBreadCrumbsShowHook( &$article ) {
global $wgOut, $wgUser;
global $wgBreadCrumbsDelimiter, $wgBreadCrumbsCount, $wgBreadCrumbsShowAnons;
if ( !$wgBreadCrumbsShowAnons && $wgUser->isAnon() )
return true;
// deserialize data from session into array:
$m_BreadCrumbs = array();
if ( isset( $_SESSION['BreadCrumbs'] ) ) $m_BreadCrumbs = $_SESSION['BreadCrumbs'];
// cache index of last element:
$m_count = count( $m_BreadCrumbs ) - 1;
// Title object for the page we're viewing
$title = $article->getTitle();
// check for doubles:
if ( $m_count < 1 || $m_BreadCrumbs[ $m_count ] != $title->getPrefixedText() ) {
if ( $m_count >= 1 ) {
# reduce the array set, remove older elements:
$m_BreadCrumbs = array_slice( $m_BreadCrumbs, ( 1 - $wgBreadCrumbsCount ) );
}
// add new page:
array_push( $m_BreadCrumbs, $title->getPrefixedText() );
}
// serialize data from array to session:
$_SESSION['BreadCrumbs'] = $m_BreadCrumbs;
// update cache:
$m_count = count( $m_BreadCrumbs ) - 1;
// build the breadcrumbs trail:
$m_trail = '<div id="BreadCrumbsTrail">';
for ( $i = 0; $i <= $m_count; $i++ ) {
$title = Title::newFromText( $m_BreadCrumbs[$i] );
$m_trail .= Linker::link( $title, $m_BreadCrumbs[$i] );
if ( $i < $m_count ) $m_trail .= $wgBreadCrumbsDelimiter;
}
$m_trail .= '</div>';
$wgOut->addHTML( $m_trail );
// invalidate internal MediaWiki cache:
$title->invalidateCache();
$wgUser->invalidateCache();
// Return true to let the rest work:
return true;
}
// Entry point for the hook for printing the CSS:
public static function fnBreadCrumbsOutputHook( &$outputPage, $parserOutput ) {
global $wgBreadCrumbsShowAnons;
if ( $wgBreadCrumbsShowAnons || $outputPage->getUser()->isLoggedIn() ) {
$outputPage->addModules( 'ext.breadCrumbs' );
}
// Be nice:
return true;
}
}
perhaps I understand it wrong:
I expected this behavior:
MainPage --> Page 1 (linked on MainPage) --> Page 2 (linked on Page 1)
When I now click on the Page 1 Breadcrumb Link I expected that it looked in that way:
MainPage --> Page 1 (linked on MainPage)
But it looks like:
MainPage --> Page 1 (linked on MainPage) --> Page 2 (linked on Page 1) --> Page 1
It would be very interesting how to change this with the options.
Best regards and thanks
yes, if you click a link in the breadcrumb trail, it should deprecate the trail to the point where you clicked, not add the new link to the end of the trail creating a looping reference of links.
How to disable breadcrumbs from appearing on the printed wiki pages please?
To hide the breadcrumbs from the page's print version add to MediaWiki:Print.css:
div#breadcrumbs { display: none; }
Post login, there is reference to non-existent pages which are actually images. Amy idea as to why this is coming in?
The images are loaded correctly from the images folder. Do not know why MW is treating the load as a page? Also, tried uploading the file itself on MW via Upload API but still issue persists.
For some reason BreadCrumbs omits certain page titles. It seems that when I go to a page that I was recently on, but have visited enough pages since to push it off of the Breadcrumbs list, when I go back it will not show the page. I do not know if this is a problem with the caching of the BreadCrumbs or what. Could it have to do with how often the cache is invalidated and the length of the BreadCrumbs shown not being the same? If the page is far enough back, it will show up in the BreadCrumbs however.
Hi all: Would it make sense to have an option where if the user clicks a previously visited page in the trail, the trail "rolls back" to that spot? Perhaps it's already there, I just haven't explored it yet! -CD
Hey CD,
I had never thought of that. I'm in the process of rewriting the whole project, and I'll take a look to see how much effort it would take to do that. Great idea! Thanks a lot.
Hey AAboyles: Way cool. Well, if you do ever get around to it, I'll test the heck outta it for ya :) Thx, CD
Hi there - Did this ever happen? I would love for this option to be applied.
I have recently installed this extension and I found that it was necessary to make a single character change, to add an ampersand, in order for the preferences to be shown.
I downloaded the "Git master" snapshot on 2013-03-22 and it was necessary to change, in BreadCrumbs.php:
function fnBreadCrumbsAddPreferences( $user, $defaultPreferences ) {
to:
function fnBreadCrumbsAddPreferences( $user, &$defaultPreferences ) {
I don't know enough about the GetPreferences hook to know if the requirement to add the & is a peculiarity of my installation, or the way that things should be. --79.98.163.245 10:55, 25 March 2013 (UTC)
No, that's definitely a bug. I'll be sure it gets fixed in the upcoming, super-charged, latest-and-greatest BreadCrumbs, powered by Javascript. Thanks for the tip!
see my commit https://gerrit.wikimedia.org/r/#/c/98246/1 (pls. merge that)
The bread crumbs appear in the right order, the only problem is that they do not appear in the right place. The bread crumbs overlap the underline of the page title.
How can it be fixed?
IE version: 8
MediaWiki 1.21.1
PHP 5.4.19 (apache2handler)
MySQL 5.5.32
Skin: Vector