Manual:$wgResourceModules
From MediaWiki.org
| Resource loader: $wgResourceModules | |
|---|---|
| Array of all extra defined modules that can later be loaded during the output. |
|
| Introduced in version: | 1.17.0 (r72349) |
| Removed in version: | still in use |
| Allowed values: | multi-dimensional array |
| Default value: | array() |
Other settings: Alphabetical | By Function
Contents |
[edit] Examples
Here's a basic example for usage in an extension. You'd put this in the main php file like /extensions/MyExtension/MyExtension.php
$wgResourceModules['ext.myExtension'] = array( 'scripts' => 'modules/myExtension.js', 'styles' => 'modules/myExtension.css', 'dependencies' => array( 'jquery.cookie', 'jquery.tabIndex', ), 'localBasePath' => dirname( __FILE__ ), 'remoteExtPath' => 'MyExtension', );
The above example will create a module called 'ext.myExtension', that includes /extensions/MyExtensions/modules/myExtension.js and /extensions/MyExtensions/modules/myExtension.css. And also ensures two modules 'jquery.cookie' and 'jquery.tabIndex' are available before execution.
[edit] Details
By default modules are registered as an instance of ResourceLoaderFileModule. You find the according code in resources/Ressources.php. Here is the documentation:
- localBasePath
- Base path to prepend to all local paths in $options. Defaults to $IP.
- Base path
- remoteBasePath
- Base path to prepend to all remote paths in $options. Defaults to $wgScriptPath.
- Base path
- remoteExtPath
- Equivalent of remoteBasePath, but relative to $wgExtensionAssetsPath.
- Base path
- scripts
- Scripts to always include.
- File path string or array of file path strings.
- languageScripts
- Scripts to include in specific language contexts.
- Array keyed by language code containing file path string or array of file path strings.
- skinScripts
- Scripts to include in specific skin contexts.
- Array keyed by skin name containing file path string or array of file path strings.
- debugScripts
- Scripts to include in debug contexts.
- File path string or array of file path strings.
- loaderScripts
- Scripts to include in the startup module.
- File path string or array of file path strings.
- dependencies
- Modules which must be loaded before this module.
- Module name string or array of module name strings.
- styles
- Styles to always load.
- File path string or array of file path strings.
- skinStyles
- Styles to include in specific skin contexts.
- Array keyed by skin name containing file path string or array of file path strings.
- messages
- Messages to always load
- Array of message key strings.
- group
- Group which this module should be loaded together with
- Group name string.
- position
- Position on the page to load this module at.
- bottom' (default) or 'top'.
[edit] Loading module
See also ResourceLoader/Migration_guide_(developers)#Adding_a_module_to_the_page:
$wgOut->addModules( 'ext.myExtension' );
[edit] See also
- $wgResourceModules: Array of all extra defined modules that can later be loaded during the output
- $wgExtensionAssetsPath: Path to extension assets - must be set for extensions to work in debug mode.
- $wgResourceLoaderMaxage:
- $wgResourceLoaderInlinePrivateModules:
- $wgResourceLoaderDebug:
- $wgResourceLoaderUseESI:
- ResourceLoader (especially Migration guide for developers to learn how to use it with Extensions)
- Manual:Hooks/ResourceLoaderRegisterModules
| Language: | English • Français |
|---|