Extension:Subpage Fun
Subpage Fun Release status: stable |
|
---|---|
Implementation | Parser function , Variable |
Description | Defines some new parser functions to get advanced information about subpages. |
Author(s) | Daniel Werner (Danwetalk) |
Latest version | 0.7.0 (2020-02-16) |
MediaWiki | 1.25+ |
Database changes | No |
License | ISC License |
Download | README RELEASE-NOTES |
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Translate the Subpage Fun extension if it is available at translatewiki.net |
The Subpage Fun extension provides your wiki with seven new parser functions/variables to get information about subpages which you can't get with MediaWikis existing magic Words. Also, this extension has a slightly different concept about what is considered a subpage than MediaWikis existing functions.
You can read almost everything you need to know about MediaWiki subpages here.
This extension goes one step further and says a subpage is not simply the part behind a slash (/
).
A page only is a subpage in case a parent page exists.
This means Subpage Fun wouldn't consider the page AC/DC a subpage as long as the page AC doesn't exist.
Assuming the page AC/DC/Discography exists, the page AC/DC/Discography/1975/1976 would have the {{SUBPAGETITLE}}
1975/1976.
The MediaWiki {{SUBPAGENAME}}
variable would only output 1976 in this case which is nonsense since this page doesn't even exist.
For developers, this extension provides the php class SubpageInfo
which can be helpful to gather information about subpages within other extensions.
Usage
Subpage Fun defines {{SUBPAGETITLE}}
, {{SUBPAGES}}
, {{PARENTPAGES}}
, {{SIBLINGPAGES}}
, {{NUMBEROFSUBPAGES}}
and {{TOPLEVELPAGE}}
.
You can use them either like that as variables for the current page or you can use them with a parameter like {{NUMBEROFSUBPAGES: Pagename}}
to use them for any page you want.
- SUBPAGETITLE
- The real name of a subpage, not only the part behind the last slash (
/
) like MediaWiki's SUBPAGENAME outputs it. - SUBPAGELEVEL
- The subpage level of a page. A normal page which is no subpage at all would return
0
. - NUMBEROFSUBPAGES
- How many subpages does a page have. Also works with subpages to see how many subpages they have. Counts all descendant pages, not only direct child pages.
- TOPLEVELPAGE
- The top level page which is the page with subpage level
0
within the same subpage tree. - SUBPAGES
- Outputs all Subpages as a comma separated list. This means all descendant pages, not only direct child pages. The output has no specific order.
- PARENTPAGES
- Outputs all ancestor pages as a comma separated list. The output begins with the top level page and ends with the direct parent page.
- SIBLINGPAGES
- Outputs all sibling pages of the same subpage level and tree as a comma separated list. The output has no specific order.
{{SUBPAGES}}
, {{PARENTPAGES}}
, {{SIBLINGPAGES}}
have a list output.
You can use this output for further use with Extension:Arrays for example.
If one function is used with parameter 1 on a page with invalid characters, the output value will be an empty string.
Advanced formatting
There are several more parameters for some functions beside 1 which is available for all functions and allows to define the page to get the information from.
- linked
- If this parameter has any value at all the pages in the list of list generating functions become links
- sep
- Allows to define a different list separator than the default separator
,
- depth
- Works with
{{SUBPAGES}}
,{{NUMBEROFSUBPAGES}}
and{{PARENTPAGES}}
. It allows to define the relative depth to the most distant page. If the depth is set to a value smaller than 0 or not set, the functions will output everything, for{{PARENTPAGES}}
a negative value will return that many elements starting from the top-level page. - filter
- Works with
{{SUBPAGES}}
,{{PARENTPAGES}}
,{{SIBLINGPAGES}}
and{{NUMBEROFSUBPAGES}}
. This parameter allows to define a regular expression (allowed delimiters/%|
, allowed modifiersimsSuUx
) which will filter all elements out of the list who don't match the expression. Alternatively, it is possible to define a simple word which must be part of a list entry or the entry won't be outputted. It is possible to define several words separated by an escaped|
for example with help of a template like Template:! using{{!}}
.
{{PARENTPAGES: linked=true |depth=1}}
will output the current page's direct parent page as link.{{PARENTPAGES: <page> |depth=-1}}
will give the same result as{{TOPLEVELPAGE}}
with the only difference that if<page>
is the top-level page already, an empty string is returned.{{SUBPAGES: somepage |depth=1 |sep=<nowiki> </nowiki>}}
will output all direct subpages below somepage seperated by a simple space.
Developers support
Developers can use some static php functions from the SubpageInfo class which delivers information about subpages which the MediaWiki Title class doesn't provide.
Installation
- <translate> [[<tvar name=2>Special:ExtensionDistributor/SubpageFun</tvar>|Download]] and move the extracted <tvar name=name>
SubpageFun
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SubpageFun - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'SubpageFun' );
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
See also
- SubPageList - Allows to list and count subpages.
- SubpageNavigation - Shows direct children of current page in article header and provides Special Page Browse subpages to browse all articles of the wiki in different modalities.
File:OOjs UI icon information-progressive.svg | <translate> This extension is included in the following wiki farms/hosts and/or packages:</translate>
<translate> This is not an authoritative list.</translate> <translate> Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.</translate> <translate> Always check with your wiki farms/hosts or bundle to confirm.</translate> |
- Pages with script errors
- Pages with broken file links
- Stable extensions
- Extensions without an image
- Parser function extensions
- Variable extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- ISC licensed extensions
- Extensions in Wikimedia version control
- GetThisVariableValueSwitch extensions
- MagicWordwgVariableIDs extensions
- ParserFirstCallInit extensions
- ParserGetVariableValueSwitch extensions
- All extensions
- Subpage extensions