Jump to content

Manual:Hooks/CategoryViewer::generateLink

From mediawiki.org
CategoryViewer::generateLink
Available from version 1.25.0
Before generating an output link allow extensions opportunity to generate a more specific or relevant link.
Define function:
public static function onCategoryViewer_generateLink( string $type, Title $title, ?string $html, string &$link ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"CategoryViewer::generateLink": "MediaWiki\\Extension\\MyExtension\\Hooks::onCategoryViewergenerateLink"
	}
}
Called from: File(s): CategoryViewer.php
Function(s): generateLink
Interface: CategoryViewer__generateLinkHook.php

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


Details

[edit]
  • $type: The category type. Either 'page', 'img' or 'subcat'
  • $title: Title object for 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