Changes

Jump to navigation Jump to search
removed {{caution}}, slight rephrasing (opening sentence)
{{Documentation subpage}}
<!-- Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->

This is the {{tl|pgn}} ('''''p'''''a'''''g'''''e'''''n'''''ame) 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:

:<code><nowiki>{{pgn|page}}</nowiki></code> = {{pgn|page}}
:<code><nowiki>{{pgn|page|page=Help:A/B/C/D}}</nowiki></code> = {{pgn|page|page=Help:A/B/C/D}}

The double usage of '''page''' might seem confusing, but it is convenient when using this template together with other templates such as {{tl|basepage subpage}} and {{tl|namespace detect}} 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 [[mw:Help:Magic words|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:

<pre>
{{pgn|ns}} = {{NAMESPACE}}

{{pgn|ss}} = {{SUBJECTSPACE}}

{{pgn|ts}} = {{TALKSPACE}}

{{pgn|ts| page=Help:A/B/C/D }} = {{TALKSPACE: Help:A/B/C/D }}
</pre>

:{{pgn|ns}}

:{{pgn|ss}}

:{{pgn|ts}}

:{{pgn|ts|page=Help:A/B/C/D}}

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

<pre>
{{pgn|page}} = {{PAGENAME}}

{{pgn|fullpage}} = {{FULLPAGENAME}}

{{pgn|ns|page}} = {{FULLPAGENAME}}

{{pgn|ss|page}} = {{SUBJECTPAGENAME}}

{{pgn|ts|page}} = {{TALKPAGENAME}}

{{pgn|ts|page| page=Help:A/B/C/D }} = {{TALKPAGENAME: Help:A/B/C/D }}
</pre>

:{{pgn|page}}

:{{pgn|fullpage}}

:{{pgn|ns|page}}

:{{pgn|ss|page}}

:{{pgn|ts|page}}

:{{pgn|ts|page| page=Help:A/B/C/D }}

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

<pre>
{{pgn|ss|page| page=Talk:An article }} = {{SUBJECTPAGENAME: Talk:An article }}

{{pgn|ns|page| page=Image:An image }} = {{FULLPAGENAME: Image:An image }}

{{pgn|ns|page| page=WP:Village pump }} = {{FULLPAGENAME: WP:Village pump }}
</pre>

:{{pgn|ss|page| page=Talk:An article }}

:{{pgn|ns|page| page=Image:An image }}

:{{pgn|ns|page| page=WP:Village pump }}

== 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:

<pre>
{{pgn|basepage}}

{{pgn|fullbasepage}}

{{pgn|ns|basepage}}

{{pgn|ss|basepage}}

{{pgn|ts|basepage}}

{{pgn|ns|basepage| page=Help:A/B/C/D }}
</pre>

:{{pgn|basepage}}

:{{pgn|fullbasepage}}

:{{pgn|ns|basepage}}

:{{pgn|ss|basepage}}

:{{pgn|ts|basepage}}

:{{pgn|ns|basepage| page=Help:A/B/C/D }}

This template can return the subpagename. Like this:

<pre>
{{pgn|subpage}}

{{pgn|subpage| page=Help:A/B/C/D }}
</pre>

:{{pgn|subpage}}

:{{pgn|subpage| page=Help:A/B/C/D }}

This template can return the rootpage. Like this:

<pre>
{{pgn|rootpage}}

{{pgn|ns|rootpage}}

{{pgn|fullrootpage}}

{{pgn|fullrootpage| page=Help:A/B/C/D }}
</pre>

:{{pgn|rootpage}}

:{{pgn|ns|rootpage}}

:{{pgn|fullrootpage}}

:{{pgn|fullrootpage| page=Help:A/B/C/D }}

== Relative paths ==

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

<pre>
{{pgn|..}}

{{pgn|ns|..}}

{{pgn|ns|..| sibling }}

{{pgn|ns|..| page=Help:A/B/C/D }}

{{pgn|ns|..| sibling | page=Help:A/B/C/D }}
</pre>

:{{pgn|..}}

:{{pgn|ns|..}}

:{{pgn|ns|..| sibling }}

:{{pgn|ns|..| page=Help:A/B/C/D }}

:{{pgn|ns|..| sibling | page=Help:A/B/C/D }}

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

<pre>
{{pgn|ns|..|..}}

{{pgn|ns|..|..| uncle }}

{{pgn|ns|..|..| page=Help:A/B/C/D }}

{{pgn|ns|..|..| uncle | page=Help:A/B/C/D }}
</pre>

:{{pgn|ns|..|..}}

:{{pgn|ns|..|..| uncle }}

:{{pgn|ns|..|..| page=Help:A/B/C/D }}

:{{pgn|ns|..|..| uncle | page=Help:A/B/C/D }}

== 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:

<pre>
{{pgn|page1| page=Help:A/B/C/D }}

{{pgn|page2| page=Help:A/B/C/D }}

{{pgn|page3| page=Help:A/B/C/D }}

{{pgn|page4| page=Help:A/B/C/D }}

+{{pgn|page4| page=Help:A/B }}+
</pre>

:{{pgn|page1| page=Help:A/B/C/D }}

:{{pgn|page2| page=Help:A/B/C/D }}

:{{pgn|page3| page=Help:A/B/C/D }}

:{{pgn|page4| page=Help:A/B/C/D }}

:+{{pgn|page4| page=Help:A/B }}+

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

<pre>
{{pgn|ns|page1|page2| page=Help:A/B/C/D }}

{{pgn|page3|page4| page=Help:A/B/C/D }}
</pre>

:{{pgn|ns|page1|page2| page=Help:A/B/C/D }}

:{{pgn|page3|page4| page=Help:A/B/C/D }}

== Parameters ==

List of all parameters:

<pre>
{{pgn| ns / ss / ts | page / basepage / rootpage | page = User:Example }}

{{pgn| fullpage / fullbasepage / subpage / fullrootpage }}

{{pgn| .. | .. }}

{{pgn| page1 | page2 | page3 | page4 }}
</pre>

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 [[meta:Link#Subpage feature|subpage feature]] enabled. Thus this template works the same in all namespaces.

This template calls {{tl|pgn/core}} which holds most of the code for {{tl|pgn}}, while {{tl|pgn}} itself does parameter preprocessing.

== See also ==
{{Namespace and pagename-detecting templates}}

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox |
| <!--Categories below this line, please; interwikis at Wikidata-->
[[Category:Namespace manipulation templates]]
[[Category:Wikipedia metatemplates]]
}}</includeonly>
Anonymous user

Navigation menu