• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

User:Davidgothberg/Pgn

  • User page
  • Talk
  • Language
  • Watch
  • Edit
< User:Davidgothberg


Documentation[view] [edit] [history] [purge]

This is the {{pgn}} (pagename) meta-template.

It helps handling pagenames, especially when working with subpages.

Contents

  • 1 The "page" parameter
  • 2 Magic words
  • 3 Namespace and pagename
  • 4 Subpages
  • 5 Relative paths
  • 6 Subpage levels
  • 7 Parameters
  • 8 Technical details
  • 9 See also

The "page" parameter

edit

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:

{{pgn|page}} = Davidgothberg/Pgn
{{pgn|page|page=Help:A/B/C/D}} = 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 {{basepage subpage}} and {{namespace detect}} that also understand the "page=" parameter.

Magic words

edit

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

edit

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

{{pgn|ns}}  = {{NAMESPACE}}

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

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

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

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

{{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 }}
Davidgothberg/Pgn
User:Davidgothberg/Pgn
User:Davidgothberg/Pgn
User:Davidgothberg/Pgn
User talk:Davidgothberg/Pgn
Help talk: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:

{{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 }}
An article
File:An image
Wikipedia:Village pump

Subpages

edit

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:

{{pgn|basepage}}

{{pgn|fullbasepage}}

{{pgn|ns|basepage}}

{{pgn|ss|basepage}}

{{pgn|ts|basepage}}

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

This template can return the subpagename. Like this:

{{pgn|subpage}}

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

This template can return the rootpage. Like this:

{{pgn|rootpage}}

{{pgn|ns|rootpage}}

{{pgn|fullrootpage}}

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

Relative paths

edit

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

{{pgn|..}}

{{pgn|ns|..}}

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

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

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

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

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

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

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

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

Subpage levels

edit

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:

{{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 }}+
A
B
C
D
++

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

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

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

Parameters

edit

List of all parameters:

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

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

{{pgn| .. | .. }}

{{pgn| page1 | page2 | page3 | page4 }}

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

Technical details

edit

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 {{pgn/core}} which holds most of the code for {{pgn}}, while {{pgn}} itself does parameter preprocessing.

See also

edit
  • v
  • t
  • e
Namespace and pagename-detecting templates
Namespace
Particular
  • Main other
  • Talk other
  • Category other
  • Draft other
  • File other
    • Is Commons
  • Help other
  • Module other
  • Portal other
  • Template other
  • User other
  • Project other
  • Single namespace
  • If talkspace of
More generic
  • Namespace detect
  • Namespace detect showall
  • Main talk other
    • Main talk other flex
  • Talkspace detect
Pagename
When on basepage
Detects and acts according to whether it is on a basepage or on any subpage (that is, a ../.. subpage).
When pagename is
For pattern matching on the pagename.
Module:Page
Can take apart and put together pagenames in several ways.
IP-talk
Returns IP-user talkpage, registered-user talkpage or non-user talkpage.
IP-user other
For detecting IP-user pages.
Subpage other
Pagename has an after-slash part (not in mainspace)
Sandbox other
Page is subpage /sandbox (template space)
Testcases other
Page is subpage /testcases (template space)
Rootpage other
Page is rootpage (vs. /subpage) (template space)
Others
Stub other
Detects whether it is on a page with a stub template or not.
Redirect other
Detects whether it is on a redirect or not.
If preview
Detects whether page is viewed as a preview or not.
If IP
Displays different content to IP users and logged-in users.
If autoconfirmed
Displays different content to autoconfirmed and non-autoconfirmed users.
If extended confirmed
Displays different content to extended confirmed and non-extended confirmed users.
If administrator
Displays content only to admins.
If mobile
Displays different content to mobile users and desktop users.
If dark
Displays different content to dark mode users and light mode users.
Noscript
Detects whether page is viewed with a JavaScript-capable client or not.
  • Wikipedia:Namespace
  • Wikipedia:Page name
  • Magic words
  • ParserFunctions
The above documentation is transcluded from User:Davidgothberg/Pgn/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this page.
Retrieved from "https://en.wikipedia.org/w/index.php?title=User:Davidgothberg/Pgn&oldid=934826280"
Last edited on 8 January 2020, at 18:41

Languages

      This page is not available in other languages.

      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 8 January 2020, at 18:41 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop