Extension:SubPageFunctions
SubPages Release status: beta |
|
---|---|
Implementation | Parser function |
Description | Automatically creates subpage links in parent page. |
Author(s) | Peter Gostelow (PeterMGtalk) |
Latest version | 0.0.3 |
MediaWiki | 1.14 |
License | GPL version 2 |
Download | LibrePlanet The parent page may need to be dummy edited to reflect subpage name changes. This may be an optimization issue. |
Example | {{#subpages: Help}} |
Translate the SubPageFunctions extension if it is available at translatewiki.net |
|
Check usage and version matrix; code metrics |
Contents
What can this extension do?[edit | edit source]
When creating a tree of subpages, this extension will provide navigation links from a parent page to its immediate subpages. It is the counterpart to the wiki's parent page links.
You may slice and dice subpage names to select parts of the name using the pathname function.
When compiling educational documents, you may create a table linking to them, using the calendar function.
The user function returns the current user name, useful when creating personalised pages.
Usage[edit | edit source]
subpages[edit | edit source]
The syntax is
{{#subpages: [NAMESPACE | 0]}}
Where
- NAMESPACE
- is an optional namespace name, e.g. Project, Help, MyNamespace, etc.
- 0 (numerical zero)
- is the main namespace, often called Article.
The default is to use the page's namespace, so you can omit the argument. You may use the function more than once for different namespaces.
You may add the function anywhere on the page. It will create a centered title and a three column list of subpage links. If there are no subpages, the function will output nothing.
pathname[edit | edit source]
The syntax is
{{#pathname: start [|length]}}
Where
- start
- An integer representing the first component in the pathname.
- length
- An integer representing the number of components.
The pathname can be trimmed from both the front or back. The length is similarly selected from either the front or back.
Given the page name
foo/bar/baz/widget/fee/fie/foe/fum
// front of name {{#pathname: 0|1}} // returns foo {{#pathname: 0|3}} // returns foo/bar/baz {{#pathname: 1|3}} // returns bar/baz/widget // back of name {{#pathname:-1}} // returns fum {{#pathname:-3}} // returns fie/foe/fum {{#pathname:-3|2}} // returns fie/foe // back length {{#pathname:3|-2}} // returns baz/widget (not widget/fee) {{#pathname:-3|-2}} // returns fee/fie (not fie/foe)
It only operates on the current page name in a similar way to {{BASEPAGENAME}} and {{SUBPAGENAME}}, so you cannot pass it arbitary text. It becomes useful when using more than three subpage levels.
calendar[edit | edit source]
The syntax is
{{#calendar: [namespace][|pageprefix]}}
Where
- namespace
- The namespace of the target pages.
- pageprefix
- The parent page in the namespace.
Returns a table where the columns are subpages of pageprefix and the rows are sub-subpages of pageprefix. If pageprefix is omitted, the current page name is used. If the namespace is omitted, the current page's namespace is used.
Given the following pages:
Extension:SubPageFunctions/example/101/intro Extension:SubPageFunctions/example/101/examples Extension:SubPageFunctions/example/102/intro Extension:SubPageFunctions/example/103/examples
the function in the Extension:SubPageFunctions page
{{#calendar: |SubPageFunctions/example}}
will produce the following table:
Module/Level | 101 | 102 | 103 |
---|---|---|---|
examples | Available | N/A | Available |
intro | Available | Available | N/A |
If a page is a redirect, it is marked as Redirect instead of Available. The row names examples and intro are composite names taken from the sub-subpages.
user[edit | edit source]
The syntax is
{{#user:}}
This function takes no arguments and returns the current logged in user name. This is useful when creating user subpages, for example, given the current user is Foo:
[[doc/example/101/examples/{{#user:}}/tutorial]]
will link to:
[[doc/example/101/examples/Foo/tutorial]]
The actual link will vary from user to user, creating multiple unique pages by user name, but each user will only see their link. The function can be used anywhere text is allowed, not just links. Most useful with SemanticMediaWiki and SemanticForms.
Download instructions[edit | edit source]
Source details can be found on LibrePlanet.
Untar the file to your MediaWiki extensions directory and follow the Installation section.
Installation[edit | edit source]
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/SubPageFunctions/SubPageFunctions.php");
Configuration parameters[edit | edit source]
No configuration parameters are available.
User rights[edit | edit source]
Default rights.
File permissions[edit | edit source]
The SubPageFunctions_magic.php file is used for language translaton, so it was considered a good idea to allow webmasters to update the file and not allow the package to overwrite it. For new installations, the package would see the file is missing and generate a default one from SubPageFunctions_magic_sample.php.
Unfortunately, this means the extension must have write permission for the extension/SubPageFunctions directory, on first installation. Every time the extension finds the magic file is missing, it will try create a new default one.
It is now considered a bad idea because webmasters may want to prevent the extension writing to the directory and preventing it will cause the extension to potentially fail with php errors.
The current release includes the magic file to avoid installation problems, but the extension will still try to create the file, if it is moved or deleted.
See also[edit | edit source]
- SubPage List, a more flexible extension.
- Multi Pages, for managing subpages.
- Subpage Fun, for parserfunctions/variables outputting informations about subpages.