Extension:CategoryBreadcrumb
From MediaWiki.org
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
|
CategoryBreadcrumb Release status: stable |
|||
|---|---|---|---|
| Implementation | User interface | ||
| Description | Displays category breadcrumbs at the article headers | ||
| Author(s) | Boudewijn Vahrmeijer | ||
| Last version | 2.2 (18-03-2013) | ||
| MediaWiki | 1.11,1.10.1/1.9.3/1.9.2/1.8.2 | ||
| License | No license specified | ||
| Download | Download http://www.leerwiki.nl/How_to_create_breadcrumb_with_Mediawiki |
||
|
|||
| Check usage and version matrix; stats | |||
Contents |
Include your working Wiki here:[edit]
What can this extension do?[edit]
It shows the category / categories as a breadcrumb at the top of the page instead of at the bottom of the page. See http://www.leerwiki.nl/How_to_create_breadcrumb_with_Mediawiki
Two simple steps
- 1) Put inside of LocalSettings.php
require_once("extensions/CategoryBreadCrumbs.php");
- 2) Create CategoryBreadCrumbs.php
Code[edit]
<?php /** * CategoryBreadcrumb extension * * @author Boudewijn Vahrmeijer * @version 2.1 * @link http://www.mediawiki.org/wiki/Extension:CategoryBreadcrumb */ if ( ! defined( 'MEDIAWIKI' ) ) die(); $wgExtensionCredits['parserhook'][] = array( 'name' => 'Category Breadcrumb', 'author' => 'Boudewijn Vahrmeijer', 'url' => 'http://www.mediawiki.org/wiki/Extension:CategoryBreadcrumb', 'version' => '2.2', 'description' => 'DMOZ-style category breadcrumb for MediaWiki', ); // hook into SkinTemplate.php $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'wfBreadCrumbsDisplay'; function wfBreadCrumbsDisplay(&$q, &$p) { global $wgOut, $wgArticle; if ($wgArticle == null) return true; if ($wgArticle->getTitle()->mNamespace != 0) return true; // get category tree $parenttree = $q->getTitle()->getParentCategoryTree(); // Skin object passed by reference cause it can not be // accessed under the method subfunction drawCategoryBrowser $tempout = explode( "\n", $q->drawCategoryBrowser( $parenttree ) ); // Clean out bogus first entry and sort them unset( $tempout[0] ); asort( $tempout ); if (empty($tempout)) { return true; } $breadcrumbs = '<div id="category-bread-crumbs">'; foreach ($tempout as $line) { $breadcrumbs .= '<div>' . $line . '</div>'; } $breadcrumbs .= '</div>'; // append to the existing subtitle text; $p->set('subtitle', $p->data['subtitle'] . $breadcrumbs); return true; } ?>
- Now you have your category breadcrumb ready.