Extension:Boilerplate

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Boilerplate

Release status: unknown

Implementation Page action
Description Load boilerplate text for a brand new page.
Author(s) User:RouslanZenetl
Version 0.0.3 (2007-11-04)
MediaWiki 1.6.8 - 1.11.0
Download Download and Installation
License
Hooks used

EditPage::showEditForm:initial

[edit] Introduction

This extension loads pre-defined text (from a page named Boilerplate that you create on your MediaWiki site) when a brand new page is created.


[edit] Download and Installation

Step 1: Copy-paste this code into a file boilerplate.php and place it in extensions directory.

<?php
 
$wgHooks['EditPage::showEditForm:initial'][] = array('boilerplate');
 
$wgExtensionCredits['other'][] = array(
        'name' => 'Boilerplate',
        'author' => '[http://rouslan.zenetl.com/ RouslanZenetl]',
        'description' => 'loads pre-defined text from [[MediaWiki:Boilerplate]] when a brand new page is created',
        'url' => 'http://www.mediawiki.org/wiki/Extension:Boilerplate'
        );
 
function boilerplate($editpage) {
 
    // EditFormPreloadText
    global $wgOut;
    $wgOut->enableClientCache(false);
 
    if (!$editpage->preview
        && !$editpage->mArticle->mContentLoaded
        && $editpage->mArticle->mTitle->mNamespace==0) {
        $boilerplate_title = Title::newFromText('boilerplate');
        $boilerplate_article = new Article($boilerplate_title);
        $editpage->textbox1=$boilerplate_article->GetContent();
        $editpage->textbox2=$editpage->textbox1;
    }
 
    return true;
 
}
 
?>

Step 2: Add the following line to LocalSettings.php:

require_once("$IP/extensions/boilerplate.php");

Step 3: Create a page named Boilerplate on your MediaWiki site. Whatever is included in this Boilerplate page will serve as the default template for any new pages created on your site.

Thats it!

[edit] License

You are free to use this extension for any reason and mutilate it to your heart's liking. If you feel your work might benefit others, post your changes here.

Personal tools