Extension:Editheader

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Editheader
Release status: beta
Description Adds a page in the MediaWiki namespace to the top of pages automatically
Author(s) Soxred93talk
MediaWiki 1.6.0+
License GPL
Download See below
Hooks used
ArticleViewHeader
Translate the Editheader extension if it is available at translatewiki.net
Check usage and version matrix.

What can this extension do?[edit]

This extension includes a system message at the top of a certain page.

Usage[edit]

To add a header to a page, create a page at "MediaWiki:Header-NS-PAGE" where NS is the numerical namespace code (e.g. 2 = User, 4 = Project) and PAGE is the page where you want it to show (excluding the namespace).

Example: To add a header on "Talk:Foo", create a page at "MediaWiki:Header-1-Foo" (page names without quotation marks, of course).

Download instructions[edit]

Please cut and paste the code found below and place it in $IP/extensions/Editheader/Editheader.php.

Installation[edit]

To install this extension, add the following to LocalSettings.php :

require_once("$IP/extensions/Editheader/Editheader.php");

Code[edit]

<?
if (!defined('MEDIAWIKI')) die();

/*
  *   Editheader extension
  *
  *   Written by Soxred93
  *
  *   Licensed under the GPL
  *
*/

$wgExtensionCredits['other'][] = array(
	   'name' => 'Editheader',

	   'author' =>'[http://en.wikipedia.org/wiki/User:Soxred93 Soxred93]',  
	   'description' => 'Adds a message to the top of a page, without using a template.',
	   'descriptionmsg' => 'editheader-desc'
	   );

$wgHooks['ArticleViewHeader'][] = 'fnEditheaderText';

function fnEditheaderText( &$article, $outputDone, $pcache ) {
    global $wgOut;

    $title = $article->mTitle->mTextform;
    $namespace = $article->mTitle->mNamespace;
    $msg = urlencode( strtolower( "header-$namespace-$title" ) );
    $x = wfMsg($msg);
    if( !wfEmptyMsg( $msg, wfMsg($x) ) ) {
        $wgOut->addWikiText( wfMsg( $source ) );
    }
    return true;
}

See also[edit]