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 manual
Crystal Clear action run.png
Add Article/Category to Category

Release status: stable

Implementation Page action
Description Adds an inputbox (for create new article or category) to each category page.

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

Author(s) Pingou (Inspired by Liang Chen The BiGreat)
Latest version 0.2 (2009-12-20)
MediaWiki 1.8+
License GPL
Download http://winux.pingou.biz/index.php/Add_Article/Category_to_Category
Example http://winux.pingou.biz/index.php/Cat%C3%A9gorie:Winux

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

Check usage and version matrix; code metrics

Installation[edit | edit source]

  1. Create file ArtCatToCategory.php in extensions directory and paste source behind.
  2. Add require_once "$IP/extensions/ArtCatToCategory.php"; to your LocalSettings.php file (near the end).
  3. Done

Source[edit | edit source]

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;

Demo[edit | edit source]

See also[edit | edit source]

Inspired by: Extension:Add Article to Category