oks
oks

Reputation: 314

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

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

Upvotes: 5

Views: 341

Answers (1)

Florian
Florian

Reputation: 2874

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.

Upvotes: 1

Related Questions