A link callback to a MediaWiki extension

93 views Asked by At

What is the most practical way of calling back into an extension from a link in the MediaWiki UI?

I have an extension that will add a link (e.g. "Report") in the history and diff pages, that needs run code in my extension.

Is it possible to have a "generic" callback URL (e.g. index.php/PageName?action=report&edit=123) or will I need to create a full special page (index.php/Special:Report?edit=123`) to handle this an execute my own code? There won't be any more UI after this beyond reporting success or failure.

1

There are 1 answers

0
Ilmari Karonen On

Both of those are possible.

There's also a third option you might want to consider:

Calling a custom API module via AJAX could offer a better user experience than just a plain link to a success / error page. For accessibility, though, you may want to provide both methods, so that your extension remains usable even for users without JavaScript support, or with JavaScript disabled. This is generally best done by writing your SpecialPage / Action and ApiBase subclasses as thin wrappers around a shared backend.