Extension:SelectCategory



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.

Stable release (recommended for most uses)
To use the stable release, download the tarball linked in the box on the right, and uncompress it. Copy the SelectCategory directory into the extensions folder of your MediaWiki installation. Then add the following lines to your LocalSettings.php file (near the end):

Download from SVN trunk
To use the current SVN version, which might be unstable and full of bugs, use the following URL for your subversion client: http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SelectCategory

$wgSelectCategoryNamespaces
This is in your SelectCategory.php file

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.


 * Example:


 * Or:

$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.

$wgSelectCategoryEnableSubpages
Defines if the extension should be active when editing subpages.

Style
To customize the design of the select box use the CSS id "SelectCategoryBox" and attach your own settings to MediaWiki:Monobook.css or your users User:USERNAME/Monobook.css.

Bugs & Feature Requests
Please file bugs and feature requests on the bug tracker on bugzilla.wikimedia.org in the bugzilla product "MediaWiki extensions" and its component "SelectCategory". You might just use this direct link that has these two settings pre-defined:


 * Bug list: https://bugzilla.wikimedia.org/buglist.cgi?component=SelectCategory&product=MediaWiki%20extensions
 * Report bug: https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions&component=SelectCategory

Fixed by users
(MediaWiki version 1.10.0) --Bennyb 15:10, 12 November 2009 (UTC)

For there are special characters such as single quote ('), double quote ("), backslash (\) in the title of categories. Fixed the error add following line at SelectCategoryFunctions.php (line 192, in function fnSelectCategoryGetChildren )  $m_root = addslashes($m_root);

To allow single quotes (') to be used, one also has to replace the following block of code at SelectCategoryFunctions.php:80

with

This extension do trim on each line of the original text, it's not good. Fixed the error at SelectCategoryFunctions.php (line 233, in function fnSelectCategoryGetPageCategories) Change from: $m_cleanText .= trim(preg_replace( "/{$m_pattern}/i", "", $m_textLine )). "\n"; To: $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ). "\n";

Only assign Category if is in a separate line
Change line 238 in SelectCategoryFunctions.php

$m_pattern = "\[\[({$m_catString}|category):([^\|\]]*)(\||)\]\]"; To: $m_pattern = "^\[\[({$m_catString}|category):([^\|\]]*)(\||)\]\]$"; so that SelectCategory only assigns a page to a category if the  is in a separate line. Previously SelectCategory broke semantic inline queries made with Semantic MediaWiki and it also assigned pages to categorys which were between nowiki-tags.

Downside: SelectCategory does not recognize any category-assignments which are not in one separate line, so if some pages in your wiki have something like the following example, SelectCategory will not recognize that Category Assignment:

...wiki text bla bla In my wiki this does not occur because the standard is to put Category-Assignments at the bottom of the page in a separate line after a newline after the text and the functionality of SemanticMedia-Inline-Queries are much more important.

See also: Compatibility Problems with SemanticMediaWiki Queries --Laquestianne 12:07, 10 March 2010 (UTC)

Special:Upload in MediaWiki 1.16
SelectCategory does not work on Special:Upload in MediaWiki 1.16 because of a change in the Mediawiki code. To make it working again, you have to
 * edit SpecialUpload.php (MediaWiki core) - see https://bugzilla.wikimedia.org/show_bug.cgi?id=25833
 * edit SelectCategoryFunctions.php - see https://bugzilla.wikimedia.org/show_bug.cgi?id=24911 (please read all comments there!)

--Cboltz 01:18, 8 November 2010 (UTC)