Extension:Editheader

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Editheader

Release status: beta

Description Adds a page in the MediaWiki namespace to the top of pages automatically
MediaWiki 1.6.0 and higher
License GPL
Download See below
Hooks used

ArticleViewHeader

Contents

[edit] What can this extension do?

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

[edit] Usage

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.

[edit] Download instructions

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

[edit] Installation

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

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

[edit] Code

<?
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;
}

[edit] See also

Personal tools