Manual:Hooks/SkinTemplateOutputPageBeforeExec

SkinTemplateOutputPageBeforeExec
Available from version 1.10.0 (r19063, codereview)
Removed in version 1.37.0 (Gerrit change 709112)
allows further setup of the template engine after all standard setup has been performed but before the skin has been rendered
Define function:
public static function onSkinTemplateOutputPageBeforeExec( &$skin, &$template ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"SkinTemplateOutputPageBeforeExec": "MediaWiki\\Extension\\MyExtension\\Hooks::onSkinTemplateOutputPageBeforeExec"
	}
}
Called from: File(s): SkinTemplate.php
Interface: SkinTemplateOutputPageBeforeExecHook.php

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


Details

edit
  • $skin: SkinTemplate
  • $template: QuickTemplate

Migration notes

edit
  Warning: If you can avoid using this hook, please do. Seek more specific hooks such as Manual:Hooks/SkinAddFooterLinks wherever you can.

This hook is deprecated since 1.35 (T60137)

Developers using this hook should instead:

  • Use Manual:Hooks/SkinAddFooterLinks if adding a link to the footer
  • To pass data to a BaseTemplate skin for rendering use OutputPage->getProperty and OutputPage->setProperty alongside one of the OutputPage hooks.
  • To update user messages, use Manual:Hooks/GetNewMessagesAlert.
  • To force an empty portal to display in the sidebar use Manual:Hooks/SkinAfterPortlet and return a non-empty string
  • For extensions which depend on other skins (for example BlueSpice / Chameleon) the skin should provide its own hook. See phab:T254300 for an example.

Example

edit
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function ( &$skin, &$template ) {
	$template->set( 'key', 'value' );
	$someVar = 'asdf';
	$template->setRef( 'key', $someVar );
	$template->data['key'];
	return true;
};