Àdàkọ:Basepage subpage

Lát'ọwọ́ Wikipedia, ìwé ìmọ̀ ọ̀fẹ́
Lọ sí: atọ́ka, àwárí


Documentation icon Aṣàlàyé àdàkọ[ìwòran] [ìtúnṣe] [ìtàn] [ìmúkúrò]

This is the {{basepage subpage}} meta-template.

This template helps other templates detect if they are on a basepage, subpage or subsubpage.

Usage[àtúnṣe | edit source]

This template takes one or more parameters, like this:

{{basepage subpage
| Basepage text
| Subpage text
}}

If the template is on the page "User:Example", it will return this:

Basepage text

If the template is on "User:Example/test" or "User:Example/test/test" or any page lower than that, it will return this:

Subpage text

This template can also detect "subsubpages", like this:

{{basepage subpage
| Basepage text
| Subpage text
| Subsubpage text
}}

If the template is on "User:Example/test/test" or any page lower than that, it will return this:

Subsubpage text

By using an empty parameter you can make it so the template doesn't render anything for some specific page type. Like this:

{{basepage subpage
| Basepage text
| Subpage text
| 
}}

The code above will render nothing when on "User:Example/test/test" or lower, but will return this when on "User:Example/test":

Subpage text

The "page" parameter[àtúnṣe | edit source]

For testing and demonstration purposes this template can take a parameter named page. Like this:

{{basepage subpage
| Basepage text
| Subpage text
| page = User:Example/test
}}

No matter on what kind of page the code above is used it will return this:

Subpage text

The page parameter makes this template behave exactly as if on that page. Thus, if a subsubpagename like "User:Example/test/test" is fed, then it returns the subsubpage text if there is one, otherwise it returns the subpage text.

The pagename doesn't have to be an existing page.

If the parameter is empty or undefined, the name of the current page determines the result.

You can make it so your template also understands the page parameter. That means you can demonstrate the different appearances of your template in the documentation for your template. Then do like this:

{{basepage subpage
| Basepage text
| Subpage text
| page = {{{page|}}}
}}

Technical details[àtúnṣe | edit source]

Templates have a problem to handle parameter data that contains equal signs "=". But that is easily solved by using numbered parameters. Like this:

{{basepage subpage
| 1 = Basepage text
| 2 = Subpage text
| 3 = Subsubpage text
| page = {{{page|}}}
}}

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

See also[àtúnṣe | edit source]

Pagename-handling and detection templates:

  • {{basepage subpage}} – For detecting if on a basepage, subpage or subsubpage.
  • {{pgn}} – Can take apart and put together pagenames in several ways.
  • {{if pagename}} – For pattern matching on the pagename.
  • {{if pagename multi}} – For pattern matching on the pagename, has input reuse.
  • {{IP-user other}} – For detecting IP-user pages.

Easy to use namespace-detection templates:

More complex namespace-detection templates:

Technical stuff:
http://yo.wikipedia.org/wiki/%C3%80d%C3%A0k%E1%BB%8D:Basepage_subpage
yo.wikipedia.org
crawl=CC-MAIN-2013-48
40729
application/http; msgtype=response
sha1:SCKALMSFEW25K4UHSRD3TVU4OOMC56R3
<urn:uuid:6457ae43-d592-4822-9cbf-a478174860df>
2013-12-05T07:20:11Z
208.80.154.225
sha1:QERL2S6GYJ2DAUTLMUWVYCBR72FPUR4Z
<urn:uuid:82cbaaff-6fd2-4d02-a174-bc2723de9263>
http://yo.wikipedia.org/wiki/%C3%80d%C3%A0k%E1%BB%8D:Basepage_subpage
response
<urn:uuid:c5d26826-61a1-4c52-8e3b-0760818e9086>
robots: classic
hostname: ip-10-33-133-15.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2013-48
operator: CommonCrawl Admin
description: Wide crawl of the web with URLs provided by Blekko for Winter 2013
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf