Available from version 1.4.3
Called before viewing a categorypage in CategoryPage::view
Define function:
public static function onCategoryPageView( &$categoryPage ) { ... }
Attach hook: In extension.json:
	"Hooks": {
		"CategoryPageView": "MediaWiki\\Extension\\MyExtension\\Hooks::onCategoryPageView"
Called from: File(s): CategoryPage.php
Interface: CategoryPageViewHook.php

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


  • $categoryPage: CategoryPage instance (CategoryPage is a subclass of Article)

If this method returns false, then the default behavior of CategoryPage::view will be skipped.


  • If there is a diff and $diffOnly is set, then the diff would be displayed and this hook won't be reached.
  • This hook is never accessed when previewing a page. The category listing is generated via EditPage::showPreview() instead of CategoryPage::view().
  • An alternative way to modify the appearance of a category page is to use the ArticleFromTitle hook, and create a new Article object using a custom class derived from CategoryPage. This method allows the category page to be customized in both preview and standard view mode. See the CategoryTree extension for an example.