Manual:Hooks/ContentGetParserOutput

From mediawiki.org
Jump to navigation Jump to search
ContentGetParserOutput
Available from version 1.24.0 (Gerrit change 67983)
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 onContentGetParserOutput( $content, $title, $revId, $options, $generateHtml, &$output ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ContentGetParserOutput": "MyExtensionHooks::onContentGetParserOutput"
	}
}
Called from:File(s): AbstractContent.php
Interface:ContentGetParserOutputHook.php

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

Details[edit]

$content
The Content object to render
$title
A Title object for the page, as context
$revId
The revision ID, as context
$options
ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state.
$generateHtml
boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object.
&$output
ParserOutput, to manipulate or replace