1

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
  • With 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?
    – leo
    Commented Nov 10, 2016 at 12:14
  • Thinking further, what I really would like to do is add a 'Check Style' button next to the Preview button that, when clicked, raises a custom even I can handle or dispatches directly to a handler. Second-best option would be a "Check Style" checkbox next to the Preview button that, in the AlternateEditPreview extension, I can programmatically check for state. I'm scraping for a clue as to how one modifies the layout of a standard page. Is it done by modifying the $editor object passed into the extension? Commented Nov 10, 2016 at 21:33
  • This is exactly what I ended up doing, and exactly what I needed - thanks! Commented Jan 3, 2017 at 16:22

3 Answers 3

1

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>";

    }
0

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.

-3

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.

2
  • 1
    Instructions 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.
    – Krenair
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.