Extension:WETitle

From WikiEducator
Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
WETitle

Release status: unknown

Implementation Parser function
Description Allows modifying the displayed title on a page.
Author(s) Jim Tittsler
Last Version 0.2 (2008-04-08)
MediaWiki 1.12 from SVN
License GPL2
Download see below
This extension is no longer active. Please use the DISPLAYTITLE magic word directly or the Template:ShortTitle or Template:MyTitle convenience templates.

What does this extension do?

The WETitle extension allows the page author to control the displayed title on a page, either limiting it to the subpage name or substituting their own complete title.


Usage

  • {{#WETitle:}} sets the displayed title to just the subpage name.
  • {{#WETitle:New Displayed Title}} sets the displayed title to New Displayed Title.

Installation

<?php

/**
* @package MediaWiki
* @subpackage WETitle
* @author Jim Tittsler <jim@exelearning.org>
* @licence GPL2
*/

if( !defined( 'MEDIAWIKI' ) ) {
        die( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
}

$wgExtensionCredits['parserhook'][] = array(
        'name'           => 'WETitle',
        'version'        => '0.2',
        'url'            => 'http://WikiEducator.org/Extension:WETitle',
        'author'         => 'Jim Tittsler',
        'description'    => 'Allow changing the displayed title of a page',
);

$wgHooks['LanguageGetMagic'][] = 'wfWETWikiWords';
function wfWETWikiWords(&$magicWords, &$langID) {
  # mark all case variations as the same
  $magicWords['wetitle'] = array(0, 'wetitle');

  return true;
}

$wgExtensionFunctions[] = 'wfWETParserFunction_Setup';
function wfWETParserFunction_Setup() {
  global $wgParser;
  $wgParser->setFunctionHook( 'wetitle', 'wfWETParserFunction');
}

$wgHooks['ParserGetVariableValueSwitch'][] = 'wfWEAssignAValue';
function wfWETParserFunction(&$parser, $param) {
  $title = trim($param);
  # if no title is supplied, use subpage name
  if ($param == '') {
    $title = $parser->mTitle->getSubpageText();
  }
  $parser->mOutput->setDisplayTitle($title);
  $parser->disableCache();
  return '';
}