[Mediawiki-l] Creating wiki pages directly by program

Rob Church robchur at gmail.com
Fri Feb 3 07:59:52 UTC 2006

A good place to look for a simple example is the
maintenance/InitialiseMessages.inc include file, which contains a
chunk that shows how to create/edit pages in a programmatic fashion.

Rob Church

On 02/02/06, Hugh Prior <mediawiki at localpin.com> wrote:
> I would like to be able to create wiki pages by just calling a function to
> which I pass the name of the new page and the text which I want on the page.
> I have managed a solution where I just hack directly into the tables
> (bypassing all the mediawiki code), but started to hit code translation type
> problems, so I think it is best to do it building on all the wisdom already
> built into the mediawiki code.
> The sort of "createPage()" function which I have so far got, but which does
> not work, is as follows:
> /**
> * Pass the name of the new page and the content and create the page
> */
> function createPage($wikiPageName, $pageText) {
>   $title = new Title();
>   $title = $title->newFromText($wikiPageName);
>   $article = new Article($title);
>   $article->insertNewArticle($pageText, "No summary", false, false);
> }
> Anybody done this before?  Any ideas what I need to do specifically to get
> this working?
> I have tried to trace through what the "index.php" file does when creating a
> page, but it's not easy to follow particularly because of the way in which
> the parameters are often implicit (e.g. via POST of form data).
> Thanks for any help!
> Hugh Prior
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

More information about the MediaWiki-l mailing list