Jump to content

Manual:Hooks/CategoryViewerGenerateLink

From mediawiki.org
CategoryViewerGenerateLink
Available from version 1.47.0 (Gerrit change 1320202)
Before generating an output link, allow extensions the opportunity to generate a more specific or relevant link.
Define function:
public static function onCategoryViewerGenerateLink( 
	IContextSource $context,
	string $type,
	PageReference $page,
	?string $html,
	?string &$link,
 ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"CategoryViewerGenerateLink": "MediaWiki\\Extension\\MyExtension\\Hooks::onCategoryViewerGenerateLink"
	}
}
Called from: File(s): Category/CategoryViewer.php
Function(s): generateLink
Interface: CategoryViewerGenerateLinkHook.php

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

Details

[edit]
  • $context: The request context.
  • $type: The category type. Either 'page', 'img', or 'subcat'
  • $page: The categorized page
  • $html: Requested HTML content of anchor
  • &$link: Returned value. When set to a non-null value by a hook subscriber, this value will be used as the anchor instead of MediaWiki\Linker\LinkRenderer->makeLink.