User:Robchurch/Categorising parser hook

From MediaWiki.org
Jump to navigation Jump to 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;
	}

}

?>