Extension:Add Article/Category to Category

From MediaWiki.org
Jump to: navigation, search

Other languages:
català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil • ‎sicilianu • ‎中文
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Add Article/Category to Category

Release status:Extension status stable

ImplementationTemplate:Extension#type Page action
DescriptionTemplate:Extension#description Adds an inputbox (to create a new article or category) to each category page.

The content of new page will contain "[[category:]]" automatically.

Author(s)Template:Extension#username Pingou (Inspired by Liang Chen The BiGreat)
Latest versionTemplate:Extension#version 0.2 (2009-12-20)
MediaWikiTemplate:Extension#mediawiki 1.8+
LicenseTemplate:Extension#license GPL
Download see below

Translate the Add Article extension if it is available at translatewiki.net

Check usage and version matrix.


  • Copy the code into ArtCatToCategory.php and place the file(s) in a directory called ArtCatToCategory in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/ArtCatToCategory/ArtCatToCategory.php";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


A Pingou's Extension for MediaWiki
Add Article/Category to Category
Inspired by Liang Chen The BiGreat
Add Article to category
Release Date: 2009/12/20
Contact: pingou@pingou.biz
Demo: winux.pingou.biz
Download: http://winux.pingou.biz/index.php/Add_Article/Category_to_Category

if( !defined( 'MEDIAWIKI' ) )

$wgExtensionCredits['other'][] = array(
    'name' => 'Add Article/Category to Category',
    'description' => 'Your MediaWiki will get an inputbox on each Category page, and you can create a new article or category directly to that category',
    'author' => 'Pingou (Inspired by Liang Chen The BiGreat)',
     'url' => 'http://winux.pingou.biz/index.php/Add_Article/Category_to_Category'
$wgHooks['EditFormPreloadText'][] = 'addcategory';
$wgHooks['CategoryPageView'][] = 'categorychange';

function addcategory(&$text)
        $cname = $_GET['category'];
        $wnew = $_GET['new'];

        if ($wnew==1)
        $temp1 ="[[Catégorie:".$cname."]]";
        return true;

function categorychange($catpage)
        $boxtext  = "Tape the article or category's name...";
        $btext = "Create";
        global $wgOut;
        global $wgScript;
        $Action = htmlspecialchars( $wgScript );

<!-- Add Article Extension Start - by Pingou -->
<script type="text/javascript">
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
function addText(thefield){
        if (thefield.value=="")
        thefield.value = thefield.defaultValue

function create_page_or_category()
        if (document.forms['createbox'].cat_or_page.value=='page')
                document.forms['createbox'].title.value = "Category:" + document.forms['createbox'].title.value ;

<!--<table border="0" align="right" width="823" cellspacing="0" cellpadding="0">-->
<table border="0" align="right" width="100%" cellspacing="0" cellpadding="0">
<td width="100%" align="right" bgcolor="">
<form name="createbox" action="{$Action}" method="get" class="createbox">
        <input type='hidden' name="action" value="edit">
        <input type='hidden' name="new" value="1">
        <input type='hidden' name="category" value="{$catpage->mTitle->getText()}">

Create a(n)
<select name="cat_or_page" id="cat_or_page">
           <option value="page">article</option>
           <option value="categorie">category</option>
in this category. Name: :

        <input class="createboxInput" name="title" type="text" value="{$boxtext}" size="42" style="color:#666;" onfocus="clearText(this);" onblur="addText(this);"/>
        <input type='button' name="create" class="createboxButton" value="{$btext}" onClick="create_page_or_category()"/>


<!-- Add Article Extension End - by Pingou -->
        return true;

See also[edit]

Inspired by Extension:Add Article to Category