Manual:Hooks/CategoryViewer::doCategoryQuery

From MediaWiki.org
Jump to navigation Jump to search
CategoryViewer::doCategoryQuery
Available from version 1.25.0 (Gerrit change 188310)
Occurs after querying for pages to be displayed in a Category page
Define function:
public static function onCategoryViewer_doCategoryQuery( string $type, IResultWrapper $result ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"CategoryViewer::doCategoryQuery": "MyExtensionHooks::onCategoryViewerdoCategoryQuery"
	}
}

For MediaWiki ≤1.25:

$wgHooks['CategoryViewer::doCategoryQuery'][] = 'MyExtensionHooks::onCategoryViewerdoCategoryQuery';
Called from:File(s): CategoryViewer.php
Function(s): doCategoryQuery

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

This hook gives extensions the opportunity to batch load any related data about the pages.

Details[edit]

  • $type: The category type as a string. Either 'page', 'file' or 'subcat'
  • $result: IResultWrapper instance, a query result from Wikimedia\Rdbms\IDatabase::select()