Open main menu

Manual:Hooks/SidebarBeforeOutput

< Manual:Hooks
SidebarBeforeOutput
Available from version 1.24.0
Called at the end of Skin::buildSidebar(), done to be used in order to alter the sidebar content just before the display
Define function:
public static function onSidebarBeforeOutput( Skin $skin, &$bar ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"SidebarBeforeOutput": "MyExtensionHooks::onSidebarBeforeOutput"
	}
}

For MediaWiki ≤1.25:

$wgHooks['SidebarBeforeOutput'][] = 'MyExtensionHooks::onSidebarBeforeOutput';
Called from:File(s): Skin.php

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

DetailsEdit

  • $skin: Skin object
  • &$bar: Sidebar contents

Modify $bar to add or modify sidebar portlets.

Warning: You should probably use SkinBuildSidebar in order to use the caching system. This hook is run on each display and should be used if the contents of the sidebar vary on a per-request basis (e.g. Extension:DynamicSidebar).

Simple ExampleEdit

$wgHooks['SidebarBeforeOutput'][] = 'fnNewSidebarItem';

function fnNewSidebarItem( $skin, &$bar ) {
        $bar[ 'name of heading' ] = array(
		array(
			'msg' => 'my-label-message',
			'href' => '//example.com'
		)
	);
        return true;
}