How to create breadcrumb with Mediawiki


NEW VERSION 24-09-2007 This article will describe how to create a breadcrumb for MediaWiki. A breadcrumb is a category tree to show the current category for an article, with all the parent categories.


Two simple steps

  • 1) Create CategoryBreadCrumbs.php

if (&#160;! defined( 'MEDIAWIKI' ) )

// See for either updates
// or other extensions such as the Ajax Rating Script-,
// Image shadow- or EditpageMultipleInputboxes extension. 
// good luck with your Wiki! 
// B.Vahrmeijer

$wgExtensionCredits['parserhook'][] = array(
'name' => 'Category Breadcrumb 24-07-2007',
'author' => 'Boudewijn Vahrmeijer',
'url' => '',
'version' => '1.11,1.10.1/1.9.3/1.9.2/1.8.2',
'description' => 'Category Breadcrumb for MediaWiki DMOZ style',

$wgUseCategoryBrowser = true;

// hook into Skintemplate.php
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = array("wfBreadCrumbsDisplay");

function wfBreadCrumbsDisplay(&$q,&$p) {
	global $wgOut,$wgArticle,$pathToRating;
	if ($wgArticle==null) return $out;	
	if ($wgArticle->getTitle()->mNamespace&#160;!= 0) return  $out;

	// get category tree
	$tree=explode('<hr />',$q->getCategories());
<p>	// kill the ugly category box below the page
    $p->set( 'catlinks', <i>);</i>
</p><p>	// set tree on top of text and register into $tpl
	$p->setRef( 'bodytext', $combine );
</p><p>	return true;
  • Second and final step: put insite Localsettings.php
$wgUseCategoryBrowser = true;
  • Now you have your category breadcrumb ready.

Risico's en Tips

  • When an articles has two categories, the breadcrumb will now show two lines.

Reacties (0)

Geen resultaten gevonden