User:It's dot com/ProjectStaticTopText

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

/** fnProjectStaticTopText *  *  Adds static text to the top of specified project pages. It particular, it forces the verbiage * about the Sandbox and Introduction instructions to automatically appear at the top of the * respective pages, eliminating the need for a template (and thus preventing vandalism). * The text itself is controlled by corresponding MediaWiki-namespace pages (in the form *  "MediaWiki:Header-pagename"). * * ©2006 by It's dot com; released under the GNU Free Documentation License, Version 1.2 or any later version */ $wgProjectStaticTopTextPages = array('Sandbox', 'Introduction'); // array of pages to be used in hook

$wgHooks['ArticleViewHeader'][] = 'fnProjectStaticTopText'; $wgExtensionFunctions[] = 'exfAddProjectStaticTopTextMessages';
 * 1) Call the hook function

function exfAddProjectStaticTopTextMessages { global $wgMessageCache, $wgProjectStaticTopTextPages; foreach ($wgProjectStaticTopTextPages as $i) $wgMessageCache->addMessages( array( strtolower( "header-$i" ) => '' ) ); // add to message cache }
 * 1) Extension to enable static-text pages to appear in the list of system messages

function fnProjectStaticTopText( &$article, $outputDone, $pcache ) { global $wgOut, $wgProjectStaticTopTextPages;
 * 1) The hook function

$title = $article->mTitle->mTextform; if ( $article->mTitle->mNamespace == NS_PROJECT &&       in_array( $title, $wgProjectStaticTopTextPages ) ) { $wgOut->addWikiText( wfMsg( strtolower( "header-$title" ) ) ); }   return true; }

?>