Extension:CategoryBreadcrumb

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
CategoryBreadcrumb

Release status: stable

Implementation User interface
Description Displays category breadcrumbs at the article headers
Author(s) Boudewijn Vahrmeijer
Last version 2.1 (21-05-2008)
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
Hooks used
SkinTemplateOutputPageBeforeExec

Check usage (experimental)

Contents

[edit] Include your working Wiki here:

[edit] What can this extension do?

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

$wgUseCategoryBrowser = true;
require_once("extensions/CategoryBreadCrumbs.php");

[edit] Code

<?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.1',
        'description' => 'DMOZ-style category breadcrumb for MediaWiki',
);
 
$wgUseCategoryBrowser = true;
 
// 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
        $tree = explode('<hr />',$q->getCategories());
 
        // kill the ugly category box below the page
    $p->set( 'catlinks', '');
 
        // set tree on top of text and register into $tpl
        $combine = $tree[1].$wgOut->mBodytext;
        $p->setRef( 'bodytext', $combine );
 
        return true;
 
}
?>
  • Now you have your category breadcrumb ready.

[edit] See also

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox