Okay, this is the code I came up with:

$wgAlreadyParsed = false;
function onParserBeforeStripSiteNotice( &$parser, &$text, &$strip_state ) {
        global $wgAlreadyParsed;
        if ( $wgAlreadyParsed ) {
                return true;
}
        $title = $parser->getTitle();
        if ( $title->getNamespace () !== 0 ) {
                return true;
        }
        $wikiPage = WikiPage::factory( $title );
        $revision = $wikiPage->getRevision();
        if ( is_null ( $revision ) ) {
                return true;
        }
        $content = $revision->getContent( Revision::RAW );
        $revisionText = ContentHandler::getContentText( $content );
        if ( $text !== $revisionText ) {
                return true;
        }
        $wgAlreadyParsed = true;
        $titleText = $title->getPrefixedText ();
        $text = "{{siteNotice|$titleText}}" . $text;
}
$wgHooks['ParserBeforeStrip'][] = 'onParserBeforeStripSiteNotice';

Then in Template:SiteNotice I put:

{{#ifeq: {{FULLPAGENAME}}|Main Page||<div class="plainlinks"
style="border:1px solid #a7d7f9; width:100%; font-size: 110%; text-align:
center; padding: 0.5ex; "><p>This page is an archive.</p></div>}}


On Wed, May 3, 2017 at 3:51 AM, Jean Valjean <[email protected]>
wrote:

> How do I put up a sitenotice for all pages except one (e.g. Main Page)? I
> want the main page to have my current content, and all other pages to have
> a notice saying their content is just an archive.
>
> I notice that when I put {{FULLPAGENAME}} in MediaWiki:Sitenotice, it
> always says "MediaWiki:Sitenotice".
>
> Otherwise, I would use an #ifeq.
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to