How can I add a checkbox to the Mediawiki Edit page? I've added an extension for the AlternateEditPreview how and want it to be optional, so would end to be able to check its state programmatically in the extension code. Cannot find an example of this kind of thing.
3 Answers
Turns out its easily solved, simply added this to our already-existing extension:
//Add "Check style" checkbox to standard Edit page
public static function onEditPageBeforeEditChecks( &$editpage, &$checks, &$tabindex )
{
$checks[] = "<input name=\"wpStylecheck\" type=\"checkbox\" value=\"1\" tabindex=\"5\" accesskey=\"x\" id=\"wpStylecheck\" /> <label for='wpStylecheck' id='mw-editpage-stylecheck' title=\"Check style [x]\">Check style</label>";
}
I would recommend investigating the WikiEditor extension. The modules are however written in JavaScript, not PHP, so you should be familiar with it before attempting to write a module.
Open your Mediawiki installation folder and navigate to
/includes/EditPage.php
make a back up copy before you
start editing.
On line 3431
the code for editing buttons begin.
-
1Instructions for modifying core like this are dreadful. On the current copy of MediaWiki I have checked out, EditPage.php's line 3431 is
$oldContent = $this->getCurrentContent();
, nothing to do with this. You didn't even specify a MediaWiki version, and even then mediawiki.org/wiki/Do_not_hack_MediaWiki_core applies.– KrenairCommented Nov 13, 2016 at 2:51 -
If you are an experienced developer who is familiar with using MediaWiki already, visit the Developer hub instead.<br>mediawiki.org/wiki/Developer_hub Commented Nov 14, 2016 at 12:18
AlternateEditPreview
you can change the edit view pretty much anyhow you want, I think. What exactly is it that is not working for you? Do you have some code to share?