User:Robchurch/Categorising parser hook

From MediaWiki.org
Jump to: navigation, search
<?php

if( defined( 'MEDIAWIKI' ) ) {

        $wgExtensionFunctions[] = 'efParserHookCategoriserSetup';
        
        function efParserHookCategoriserSetup() {
                global $wgParser;
                $wgParser->setHook( 'stuff', 'efParserHookCategoriserRender' );
        }
        
        function efParserHookCategoriserRender( $input, $args, $parser ) {
                # Categorise so we can find this page later
                $cat = Title::makeTitle( NS_CATEGORY, 'Pages using Stuff' );
                $parser->mOutput->addCategory( $cat->getDBkey(), $parser->mTitle->getPrefixedText() );
                # Do some parser hook stuff here
                $blah = 'foo bar baz';
                return $blah;
        }

}

?>
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox