Extension:Simple Breadcrumb
![]() Release status: stable |
|
---|---|
Implementation | Parser function , Hook |
Description | Implements a simple hierarchical breadcrumb |
Author(s) | Nicolas Bernier, Jeffrey C. Parry |
Latest version | 2.0 (2023-09-11) |
MediaWiki | 1.39+ |
PHP | 5.2.4 |
Database changes | Yes |
License | GNU Lesser General Public License 3.0 only |
Download | Download master snapshot Note: README |
The extension implements a {{#breadcrumb: }} tag to set a parent page for each page. The resulting breadcrumb is displayed under the page title.
Usage
editJust add a {{#breadcrumb: }} tag anywhere in your page to set its parent and its (the current page's) alias.
{{#breadcrumb: Parent_Page | Alias}}
The alias will replace the page's name in the breadcrumb trails for all descendant pages, in addition to the current page. The page at the top of the hierarchy (i.e., the page that has no parent) may still be given an alias, which will show up in all the descendants' breadcrumb trails. The top page will not display a breadcrumb.
The tag can be used in templates and accepts magic words.
{{#breadcrumb: Category:Releases {{{product}}} | {{SUBPAGENAME}} }}
You should not add more than one breadcrumb tag in each page. In experimentation, if there are two breadcrumb tags, the second one is the one that is effective, but this behavior is not tested.
Installation
edit- Download and place the file(s) in a directory called
Simple Breadcrumb
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Simple Breadcrumb' );
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration
editThe extension offers a bunch of configuration variables that can be overridden in LocalSettings.php after the inclusion of the extension.
$wgbcdelimiter = ' > '; // Breadcrumb delimiter string
$wgbcMaxCount = 5; // Maximum elements in breadcrumb
$wgbcOverflowPrefix = '…'; // Prefix when breadcrumb has more elements than fixed limit
The extension adds the class "breadcrumbs-page" to the tag on pages where the parser tag is used. This allows the use of CSS styles for such pages (for example, to suppress subpage breadcrumbs on only those pages where this extension is invoked). To do so, the following could be added to Mediawiki:Common.css.
/* Hide parent breadcrumbs on subpages*/
.breadcrumbs-page .subpages {
display: none !important;
}
Working Example
editFor a working example of this extension in action, go to https://www.wikilawschool.org/wiki/Constitution_of_the_United_States/Art._I/Sec._8/Clause_3_Commerce. The {{#breadcrumb: }} parser tag is invoked there by this template: https://www.wikilawschool.org/wiki/Template:Breadcrumb.