Manual:Hooks/OutputPageBodyAttributes

From Proactive Programming
Jump to: navigation, search

[[Category:MediaWiki hooks{{#translation:}}|OutputPageBodyAttributes]] [[Category:Hooks added in MediaWiki 1.17.0{{#translation:}}|OutputPageBodyAttributes]]

OutputPageBodyAttributes
Available from version 1.17.0
Called when OutputPage::headElement() is creating the body tag.
Define function:
public static function onOutputPageBodyAttributes( OutputPage $out, Skin $skin, &$bodyAttrs ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"OutputPageBodyAttributes": "MyExtensionHooks::onOutputPageBodyAttributes"
	}
}

For MediaWiki ≤1.25:

$wgHooks['OutputPageBodyAttributes'][] = 'MyExtensionHooks::onOutputPageBodyAttributes';
Called from:File(s): OutputPage.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see [[:Category:OutputPageBodyAttributes extensions{{#translation:}}]].

Details

Allows extensions to add attributes to the body of the page they might need. Or to allow building extensions to add body classes that aren't of high enough demand to be included in core.

  • $out: The OutputPage which called the hook, can be used to get the real title
  • $skin: The Skin that called OutputPage::headElement
  • &$bodyAttrs: An array of attributes for the body tag passed to Html::openElement