Wikimedia Developer Support

Extension Is not recognizing the tag on mediawiki page

Hi Everyone,

I am trying to create an extension which renders a Dynamic table on a mediawiki page which uses javascript. I looked at many extension and created something like this:

//registering the <Filter/> tag
public static function onParserFirstCallInit(Parser &$parser ) {
	$parser->setHook( 'Filter', [ 'DisplayFilter', 'getParserHandler' ] );
}

// Callback function for onParserFirstCallInit()
public static function getParserHandler( &$parser ) {
	$po = $parser->getOutput();
	$po->updateCacheExpiry( 0 );
	$title = $parser->getTitle();
	
	// Add required CSS & JS via ResourceLoader
	$po->addModuleStyles( 'ext.Filter.css' );
	$po->addModules( 'ext.Filter.js' );
	
	$output = '<div>';
	$output .= '<span> Hello </span>';
	$output .= '</div>';
	return $output;
}

The extension is successfully registered in Special: Versions.
But, it is not recognizing the tag on mediawiki pages

Maybe someone can help me out?

Thankyou
Yousaf

1 Like

That’s not how the signature of the parser hooks looks. Check the examples in the manual on tag extensions.

(Note that the syntax for integrating with the parser is about to change for 1.35. Look for a mailing list announcement soon.)

1 Like