在哪里调用addModules()? [英] Where to call addModules()?

查看:85
本文介绍了在哪里调用addModules()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我所有的Wiki页面上添加一些脚本和样式. 因此,我创建了文件/extensions/MyExtension/MyExtension.php,并输入了以下数组:

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.

推荐答案

通常,您将实现 BeforePageDisplay 钩子,并使用在那里收到的OutputPage对象.

Typically you would implement the BeforePageDisplay hook and use the OutputPage object received there.

这篇关于在哪里调用addModules()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆