问题
I would like to add some scripts and styles to all my wiki pages. So I have create the file /extensions/MyExtension/MyExtension.php and I put a following array like this:
$wgResourceModules['ext.MyExtension.foo'] = array(
'scripts' => 'modules/ext.MyExtension.foo.js',
'styles' => array('modules/ext.MyExtension.foo.css','modules/ext.MyExtension.bar.css'),
'localBasePath' => __DIR__,
'remoteExtPath' => 'MyExtension',
);
But in the documentation they say that I have to call
$this->getOutput()->addModules( 'ext.myExtension' );
but I don't know where I have to call it.
回答1:
Typically you would implement the BeforePageDisplay hook and use the OutputPage object received there.
来源:https://stackoverflow.com/questions/31626025/where-to-call-addmodules