Extension:JSBreadCrumbs

From mediawiki.org
MediaWiki extensions manual
JSBreadCrumbs
Release status: stable
Implementation Skin
Description Adds a trail of breadcrumbs below the tab bar.
Author(s)
Latest version 1.1.1 (2023-06-24)
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.29+
PHP 5.5+
Database changes No
License GNU General Public License 2.0 or later
Download
  • $wgJSBreadCrumbsGlobalMaxCrumbs
  • $wgJSBreadCrumbsCSSSelectorHorizontal
  • $wgJSBreadCrumbsCSSSelectorVertical
  • $wgJSBreadCrumbsHorizontalSeparator
Quarterly downloads 44 (Ranked 106th)
Translate the JSBreadCrumbs extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The JSBreadCrumbs extension is a simple extension that adds a jQuery-based JavaScript file and a CSS file to your wiki's output that will add a trail of navigation bread crumbs below the navigation tabs. The idea is for a simpler history than your back button that only tracks navigation inside of the wiki. Unlike the browser's back button, it will only track GET requests, not POSTs, and will remove duplicate entries from the list.

Supports multiple MediaWiki skins including Vector, MonoBook, Foreground and Chameleon. Except for Vector vertical bread crumbs are not supported.

This extension creates breadcrumbs in the traditional "How did I get here?" sense; use Extension:BreadCrumbs2 for breadcrumbs in the category-based "Where am I?" sense.

Installation[edit]

  • Download and move the extracted JSBreadCrumbs folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/JSBreadCrumbs
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'JSBreadCrumbs' );
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

Configuration parameters[edit]

There are four configuration parameters that may be specified in "LocalSettings.php":

Configuration Flag Default Value Description
$wgJSBreadCrumbsHorizontalSeparator "" The separator used between bread crumbs when used in horizontal mode. If left blank (the default value), the value of the jsbreadcrumbs-horizontal-separator message will be used.
$wgJSBreadCrumbsCSSSelectorHorizontal [] An array of mappings from skin to the CSS selector that should be used to anchor the bread crumb trail when displaying bread crumbs in horizontal mode while using that skin. There is a default mapping of skin to CSS selector for horizontal mode that is used if no value exists for a skin in this array.
$wgJSBreadCrumbsCSSSelectorVertical [] An array of mappings from skin to the CSS selector that should be used to anchor the bread crumb trail when displaying bread crumbs in vertical mode while using that skin. There is a default mapping of skin to CSS selector for vertical mode that is used if no value exists for a skin in this array.
$wgJSBreadCrumbsGlobalMaxCrumbs 20 The maximum number of bread crumbs that will be saved in the cookie for a domain. If multiple wikis exist on the same domain, this value will limit the total number of bread crumbs summed across all of those wikis. This can help to prevent the cookie value from becoming too large and causing a browser error.

User Preference Options[edit]

In addition, there are 8 user preference options. These have default values that can be overridden in LocalSettings.php (see below). Users can then override those default values by visiting Special:Preferences and editing them on the Appearance tab. The user preference options are:

User Preference Option Default Value Description
jsbreadcrumbs-showcrumbs true Controls whether a bread crumb trail will be displayed.
jsbreadcrumbs-numberofcrumbs 5 The maximum number of crumbs displayed in the bread crumb trail.
jsbreadcrumbs-horizontal true If true, the bread crumb trail will be a horizontal list. If value, it will be a horizontal list.
jsbreadcrumbs-maxlength-horizontal 40 The maximum length of the link text for a bread crumb (not including the optional action or site name) when in horizontal mode.
jsbreadcrumbs-maxlength-vertical 20 The maximum length of the link text for a bread crumb (not including the optional action or site name) when in vertical mode.
jsbreadcrumbs-showaction false If false, page links with actions associated them (e.g. ?action=historyor ?action=edit) will not generate separate bread crumbs. Instead, a link to the page without the associated action will be used. If true, each action will create its own bread crumb, and the action will be shown after the page name. If there is a localized message string for the action, that will be used.
jsbreadcrumbs-showsite false If true, the name of the wiki will be shown before the page name. This is useful in wiki farms if the user wants to distinguish between links to different wikis on the same domain.
jsbreadcrumbs-domain false If true, the bread crumb trail may include bread crumbs from any wiki on the same domain as the wiki for the currently displayed page. If false, only bread crumbs from the current wiki will be displayed.

To override the default value of a user preference option, you can put code similar to the code below in your "LocalSettings.php". That is, with this code in "LocalSettings.php", the value of jsbreadcrumbs-maxlength-horizontal used for a user if they do not edit the value in Special:Preferences will be 50 rather than the default value of 40 provided in "extension.json".

$wgDefaultUserOptions['jsbreadcrumbs-maxlength-horizontal'] = 50;

Cookies[edit]

This extension uses a cookie, mwext-jsbreadcrumbs, to store the breadcrumb trail for a period of 30 days.

Changelog[edit]

1.1.1
  • Avoid getting page props on special pages like Special:UserLogin
  • Replace usage of deprecated PageProps::getInstance()
  • Use UserOptionsLookup::getOption instead of deprecated User::getOption
  • Add Secure and SameSite to the cookie
1.1.0
  • Added support for MediaWiki 1.35
1.0.3
  • Fixed issue adding breadcrumbs to trail.
1.0.2
  • Fixed a rendering issue for Internet Explorer 11
1.0.1
  • Fixed the mechanics of a system message
  • Translation updates
1.0
  • The extension code was significantly refactored. New configuration options and user preferences were created as documented above. Changes included:
    • converted to extension registration
    • localized hard-coded English text
    • replaced non-working pervasive wiki farm option with jsbreadcrumbs-domain user option
    • reworked CSS options
    • added global maximum crumbs in addition to site maximum
    • made maximum length of displayed crumbs configurable
    • optionally added localized action name to the end of crumb for action other than view (e.g. edit, history)
  • Translation updates
0.7.0
  • Removed I18n shim for php
  • Provided license information
0.6.1
  • Added capability to support additional skins
    • Added capability to specify additional skin -> CSS mappings in code and LocalSettings.php
    • Added dynamic "lookup" of user's current skin and will apply skin->CSS mapping dynamically
  • Added capability for sidebar view vice topbar view
  • Added support for SemanticTitle (does not require SemanticTitle to be present)
  • Removed seperate jquery.cookie library
  • Added ResourceLoader code to load mediawiki.cookie
  • Fixed random === critques
  • Set "show crumbs" to true by default
  • Updated variable usage to use mw.config due to deprication
  • Added variable for "pervasive wiki farm" linking
  • Changed "cookie link" storage and checking for duplicates to prevent issue when using query parameters causing duplicate crumbs
  • Changed way extension passes JavaScript config parameters to BreadCrumbs.js as we were experiencing a situation where parameters were not being passed to some instances of Mediawiki
0.6
  • I18n migrated to json
0.5
  • Changed the display of site names to (sitename) from sitename: to make a visual difference between project namespace, and site name
0.4
  • Added different site name support (when bread crumbs are enabled on wiki farma, and they share the same cookie path)
  • Added support for preferences
    • Users can enable/disable bread crumbs
    • Users can enable/disable prepending sitename on titles
    • Users can set the number of bread crumbs to display
  • Delete cookies on log out
  • Removed some global preferences (replaced with default user options)
  • Fixed localization issue with namespaces
  • Only output JavaScript/CSS when using the Vector skin
0.3
  • Display wgTitle instead of wgPage to avoid url encoded titles
  • Fix issue where wgJSBreadCrumbsMaxCrumbs + 1 number of bread crumbs were shown instead wgJSBreadCrumbsMaxCrumbs
  • Strip empty title and url when it exists
  • Change the output of the leading description to look like "Leading description:" instead of "Leading description " + wgJSBreadCrumbsSeparator, to make it more clear that it isn't part of the history.
  • Change the character used to split and join in cookies to '|' since it is illegal in urls and page titles, and therefore is guaranteed to work, unlike using the user overridable separator
  • Make addResources in JSBreadCrumbs.hooks.php public and static to get rid of php warning
0.2
  • Allow the separator character to be localized
  • Add preceding string to the bread crumbs to describe their purpose on initial page load
0.1
  • Initial commit