Extension:SelectCategory
Release status: beta |
|
|---|---|
| Implementation | Page action |
| Description | Allows the user to select categories from existing ones when editing a page or uploading a new file. |
| Author(s) |
|
| Latest version | 1.2.0 (2025-08-04) |
| Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
| License | GNU General Public License 2.0 or later |
| Download | README CHANGELOG |
|
|
|
| Translate the SelectCategory extension if it is available at translatewiki.net | |
| Issues | Open tasks · Report a bug |
The SelectCategory extension provides three functions:
- It shows a list of all categories (unless a custom root category is configured) in their hierarchical structure on the edit page.
- It strips all categories linked within a page upon editing and selects them in the category list list.
- It adds selected categories from the list to the text body of the page on saving.
Download
[edit]The extension can be retrieved directly from Git [?]:
- Browse code
- Some extensions have tags for stable releases.
- Browse tags
- Select the tag
- Click "snapshot"
- Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).
- Browse branches
- Select a branch name
- Click
Continue
Extract the snapshot and place it in the extensions/SelectCategory/ directory of your MediaWiki installation.
If you are familiar with Git and have shell access to your server, you can also obtain the extension as follows:
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SelectCategory.git
Installation
[edit]- Download and move the extracted
SelectCategoryfolder to yourextensions/directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SelectCategory
- Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'SelectCategory' );
- Configure as required
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration
[edit]$wgSelectCategoryNamespaces
Defines in which namespaces the extension should be active.
All namespaces are already predefined in the array. Set a specific namespace to true to enable or to false to disable the extension.
Active per default are: Media, Main, Project, Image, Help, Category.
$wgSelectCategoryNamespaces[NS_PROJECT] = false;
$wgSelectCategoryNamespaces[NS_CATEGORY] = false;
or
$wgSelectCategoryNamespaces = array(
NS_MEDIA => true,
NS_MAIN => true,
NS_TALK => false,
NS_USER => false,
NS_USER_TALK => false,
NS_PROJECT => true,
NS_PROJECT_TALK => false,
NS_IMAGE => true,
NS_IMAGE_TALK => false,
NS_MEDIAWIKI => false,
NS_MEDIAWIKI_TALK => false,
NS_TEMPLATE => false,
NS_TEMPLATE_TALK => false,
NS_HELP => true,
NS_HELP_TALK => false,
NS_CATEGORY => true,
NS_CATEGORY_TALK => false,
100 => true, // customized namespace, e.g. ''Portal'', c.f. [[Manual:Using custom namespaces]]
101 => false // customized namespace, e.g. ''Portal talk'', c.f. [[Manual:Using custom namespaces]]
);
$wgSelectCategoryRoot
Set a specific root category depending the namespace. Only categories within this root will be displayed when editing a page in a certain namespace.
Useful on big wiki sites to keep the database load down.
If not set (default) the extension searches for all root categories and displays them including all children.
$wgSelectCategoryRoot = array(
NS_MEDIA => false,
NS_MAIN => "My Article Root Category",
NS_TALK => false,
NS_USER => false,
NS_USER_TALK => false,
NS_PROJECT => false,
NS_PROJECT_TALK => false,
NS_IMAGE => "My Image Root Category",
NS_IMAGE_TALK => false,
NS_MEDIAWIKI => false,
NS_MEDIAWIKI_TALK => false,
NS_TEMPLATE => false,
NS_TEMPLATE_TALK => false,
NS_HELP => false,
NS_HELP_TALK => false,
NS_CATEGORY => false,
NS_CATEGORY_TALK => false
);
$wgSelectCategoryChosenMode
Defines if Chosen should be used for selection. true by default. Set this to false to use the older treeview-based selector instead.
$wgSelectCategoryEnableSubpages
Defines if the extension should be active when editing subpages.
$wgSelectCategoryEnableSubpages = false;
$wgSelectCategoryEnableOnEditPage
Defines if the extension should be active when editing pages. false by default, i.e. the extension is not active on ?action=edit.
$wgSelectCategoryEnableOnEditPage = false;
$wgSelectCategoryEnableOnUploadForm
Defines if the extension should be active on Special:Upload; true by default.
$wgSelectCategoryEnableOnUploadForm = true;
$wgSelectCategoryToplevelAllowed
Should the top-level category be allowed for selection (false will hide the checkbox for it)? true by default.
Note: if you set this to false, articles in the top-level category will be removed from this category on next edit.
Style
[edit]To customize the design of the select box, use the CSS ID "SelectCategoryBox" and attach your own styles to [[MediaWiki:Monobook.css]] or your users' [[User:USERNAME/monobook.css]].
Bugs & Feature Requests
[edit]Please file bugs and feature requests in the bug tracker on phabricator.wikimedia.org. You might just use this direct link that has these two settings pre-defined:
- Beta status extensions
- Page action extensions
- GPL licensed extensions
- Extensions in Wikimedia version control
- EditPage::showEditForm:initial extensions
- EditPage::attemptSave extensions
- UploadForm:initial extensions
- UploadForm:BeforeProcessing extensions
- BeforePageDisplay extensions
- All extensions
- Edit extensions
- Category extensions
