Template:Pgn/doc

This is the or pagename meta-template.

It helps handling pagenames, especially when working with subpages.

The "page" parameter
The operations this template does is normally based on the pagename of the page it is used on. But any other pagename can be fed as the "page=" parameter. Note that there are two different page parameters. Like this:



The double usage of page might seem confusing, but it is convenient when using this template together with other templates such as and  that also understand the "page=" parameter.

Magic words
Some of the functions in this template are mostly here for completeness. When there is an exactly equivalent magic word that works in all namespaces, then it is also listed in these examples. We recommend you use the magic word if there is one, since that is more efficient. It is when working with subpages that this template excels.

Namespace and pagename
This template can return the current namespace, subject space and talk space. Like this:

=

=

=

=









This template can return the pagename, and it can combine the pagename with the namespace, subject space or talk space. Like this:

=

=

=

=

=

=













This template correctly removes the colon ":" for the main (article) space. It also converts namespace aliases such as "Image" to "File". Like this:

=

=





Subpages
The following examples are about subpages. To see them correctly view this documentation at Template:Pgn/doc instead.

This template can return the basepagename of the current page, and it can combine the basepagename with the namespace, subject space or talk space. Like this:













This template can return the subpagename. Like this:





This template can return the rootpage. Like this:









Relative paths
This template can handle relative paths. And it can take the name of a subpage to add to the path. Like this:











This template can handle relative paths up to two levels deep:









Subpage levels
This template can split up and handle each level in a pagename, in up to four subpage levels. (The "+ +" used in this example is to show when this template returns an empty string.) Like this:

++











And it can put the parts together in pretty much any way you want. Like this:





Parameters
List of all parameters:

Note that several of the parameters can be fed to more than one position.

Technical details
This template detects subpages even when used in namespaces that don't have the MediaWiki subpage feature enabled. Thus this template works the same in all namespaces.

This template calls which holds most of the code for, while  itself does parameter preprocessing.