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.

You will need MediaWiki version 1.9 for this extension to work
 * Please notice:

or use SVN with revision 18308

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):

require_once( 'extensions/SelectCategory/SelectCategory.php' );

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.

$wgSelectCategoryNamespaces[NS_PROJECT] = false; $wgSelectCategoryNamespaces[NS_CATEGORY] = false;
 * Example:

$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 );
 * 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.

Example
$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  );

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

Example
$wgSelectCategoryEnableSubpages = false;

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
No known bugs at the moment, but feel free to complain :-) --LeonWeber 21:28, 1 December 2006 (UTC)

if a category name has an apostrophe in it, a mysql error occurs in the fnSelectCategoryGetChildren function add this line before the sql query to fix the problem: $m_root = str_replace("'","\'",$m_root);

You should at least use v0.3 as there was a bad bug in v0.1 and minor bugs in v0.2 --Manuel Schneider(bla) (+/-) 17:58, 17 December 2006 (UTC)
 * leading spaces: If you're useing leading spaces, all of them will disappear after clicking "show preview". Just "save page" is working correctly. &lt;pre&gt; works, but its indentation is still lost.
 * This can be resolved by removing the first trim in the fnSelectCategoryGetPageCategories function; see 9848 for a patch.
 * Dont combine SelectCategory with the extension "RequireCategory" ... it doesnt work! --Nyks 01:16, 21 December 2006 (UTC)
 * I am running 1.9. when I install this extension I just get a blank page when editing. --Magick 10:46, 12 January 2007 (UTC)
 * It doesn't detect cycles in the category graph, so editing just seems to hang if it hits one. -Steve Sanbeg 19:16, 19 January 2007 (UTC)
 * I cannot add an article to a new (not existing) category by adding it in the wiki way (I mean by adding at the end of an article)
 * Clicking "Show Preview" in the editor causes all categories to be cleared. See 9849 for a patch.
 * Selecting no categories causes a PHP warning to be shown when saving. See 9847 for a patch.
 * Adding a new category while editing a single section leads to an entry at the end of the edited section, not at the end of the page. --WIKImaniac 11:57, 6 July 2007 (UTC)

Feature Requests

 * It would be nice to incorporate the creation of additional categories into this extension. --Oreo masta 17:40, 12 February 2007 (UTC)
 * The UI makes it too easy to erase all your carefully assigned categories from a page. One accidental mouseclick (on the category list) will deselect all the categories on a page. I suggest you make the category list read-only, and add a dropdown with buttons to "add category" and "remove category" through JavaScript. Also add a "Revert" button to go back to the original saved set of categories. Otherwise this extension is too dangerous to existing categories on a page.