Extension:NamespacePreload
Release status: stable |
|
|---|---|
| Implementation | Page action |
| Description | Preloads templates on new pages based on their namespace |
| Author(s) | Ostrzycieltalk |
| Latest version | 1.2.0 |
| Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
| MediaWiki | 1.30+ (I think) |
| PHP | 7.3+ |
| Database changes | No |
| License | GNU General Public License 2.0 or later |
| Download | GitLab: Note: |
|
|
The NamespacePreload extension lets you define namespace-specific text that should be preloaded on new pages (that is, shown in the wiki editor when users begin to create a missing page). This can be useful if you want to maintain a consistent style in the text structure, template use, or categorization of pages in different namespaces.
Pre-save transforms can be optionally applied before showing the edit page to the user. See: Configuration.
Installation
[edit]- Download and place the file(s) in a directory called
NamespacePreloadin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'NamespacePreload' );
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration
[edit]The following variables are provided:
- $wgNamespacePreloadDoExpansion
- Whether to expand templates of the preloaded text. Default value is true.
- $wgNamespacePreloadDoPreSaveTransform
- Whether to apply pre-save transforms to the preloaded text before showing the edit page to the user. Default value is false.
Usage
[edit]To define text that should be preloaded for a namespace, first you have to determine the namespace ID.
Please refer to the MediaWiki docs on how to do this.
Once you obtain your namespace ID, create a page named MediaWiki:Preload-namespace-<namespace ID> containing the text to be preloaded in that namespace.
For example, if you want to define a preload for the main namespace (ID 0), you should save it to the page MediaWiki:Preload-namespace-0.
Template expansion
[edit]When $wgNamespacePreloadDoExpansion is set to true (the default value), all templates in the preload message will be expanded before displaying the edit form. You can disable that for all namespaces using this configuration setting.
You can also disable expansion selectively by using a template or <nowiki> element to prevent the parser from recognizing the template call.
For example, if your preload message contains {{SomeTemplate}} and you want that literal text to be shown in the wiki editor, you can use <nowiki>{{</nowiki>SomeTemplate}} or something like {{((}}SomeTemplate}}, assuming Template:(( on your wiki generates the text {{.
| This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
