Manual:Hooks/ContentAlterParserOutput

From MediaWiki.org
Jump to navigation Jump to search
ContentAlterParserOutput
Available from version 1.25.0 (Gerrit change 161471)
Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content.
Define function:
public static function onContentAlterParserOutput( $content, $title, &$output ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ContentAlterParserOutput": "MyExtensionHooks::onContentAlterParserOutput"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ContentAlterParserOutput'][] = 'MyExtensionHooks::onContentAlterParserOutput';
Called from:File(s): AbstractContent.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:ContentAlterParserOutput extensions.

Details[edit]

Modifies the parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called (such as adding tracking categories based on the rendered HTML).

$content
The Content to render
$title
Title of the page, as context
$parserOutput
ParserOutput to manipulate