Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you load the css for a Mediawiki tag extension?

Tags:

css

php

mediawiki

How do you load the css for an extension?

Using Mediawiki 1.25.2, I copied the boiler plate extension and edited extension.json to include

   "Hooks": {
            "BeforePageDisplay": [
                    "FinancialMathematicsHooks::onBeforePageDisplay"
            ],...
    },
    "ResourceModules": {
                  "ext.FinancialMathematics": {
                          "styles": [
                              "modules/ext.FinancialMathematics.css"
                               ]
                     }
      }

and in the hooks file I added

    public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
            $out->addModuleStyles( 'ext.FinancialMathematics' );
            return true;
    }

but the extension doesn't include the css.

The extension is installed on a wiki here and the complete code for the extension is on github

like image 674
oks Avatar asked Nov 09 '22 04:11

oks


1 Answers

You should check, if the module is loaded correctly. The easiest way is by using the browser's console and run the following command:

mw.loader.getState("ext.FinancialMathematics");

You will get a state, on your page with the given module error. So check the output of the load request (using the browser's network tab or use the direct load.php url). You will get an output with a starting comment which says Internal Error. So, please check your error log on the server to see a full error message and a stack trace to debug this error.

like image 185
Florian Avatar answered Nov 14 '22 21:11

Florian