Jump to content

Manual talk:Hooks/SkinTemplateOutputPageBeforeExec

Add topic
From mediawiki.org
Latest comment: 2 years ago by 109.147.192.55 in topic No way now of editing my footer links

When I try to use this hook in an extension, the MediaWiki page shows lots of warnings like this:

Warning: Cannot modify header information - headers already sent by (output started at (myexteion).php:14) in includes/WebResponse.php on line 1

Is this hook not suited for use in an extension? How can these warnings be suprssed?

[edit]

Add in LocalSettings.php to suppress "User contributions" link in the toolbox for non-sysops (tested with MediaWiki 1.15.1 --Wikinaut 17:29, 7 January 2010 (UTC)).Reply

$wgGroupPermissions['*']['listcontributions'] = false;
$wgGroupPermissions['sysop']['listcontributions'] = true;

// disable "User contributions" in the toolbox, if the user is not allowed to use it 
function StripContributions( &$templateengine, &$template ) { 
	global $wgUser;
	if ( !$wgUser->isAllowed( 'listcontributions' ) ) {
		unset( $template->data['nav_urls']['contributions'] );
	}
    return true;
}
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'StripContributions';

Note:
This code suppresses only the link in the toolbox. Read here, how disable the Special:Contribution page as such.

signature

[edit]

The call in SkinTemplate.php is wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ), so the first argument is a SkinTemplate object, and the second is a "template" object, apparently usually (always?) a subclass of QuickTemplate. I'm not sure what kinds of objects are supposed to be referred to by $template and $templateEngine in the current page's text, so I haven't changed it. Does anyone know how veteran MW hackers would naturally interpret variables named $template and $templateEngine?

This hook seems like a bad idea

[edit]

It allows people to redefine what template variables shared across various skins mean [1]

Use cases like suppressing User:Contributions feel like they would be better done if they were built into core?

[1] http://thread.gmane.org/gmane.science.linguistics.wikipedia.technical/74230 Jdlrobson (talk) 19:22, 6 December 2013 (UTC)Reply

[edit]

No now there's no way now that I can change my footer links since SkinTemplateOutputPageBeforeExec was removed. I have tried reading Manual:Footer but can't make any sense of it at all. What I tried there had no affect at all on my footer links and everything I find online about editing footer links says to use SkinTemplateOutputPageBeforeExec. Why the hell remove such an essential feature??? You lot are bloody balmy. 109.147.192.55 11:55, 27 June 2022 (UTC)Reply