Documentation icon ފަންވަތް ޑޮކިއުމަންޓޭޝަން[view] [edit] [history] [ޕާރޖް]
This is the

{{When on basepage}} meta-template. It helps other templates detect if they are on a basepage (i.e. a page whose name matches the pattern "x:x") subpage ("x:x/x") or subsubpage ("x:x/x/x").

An alternative way to detect whether a page is a subpage is to combine the parser functions #ifeq: and #titleparts. See Alternatives for simpler text below.

{{When on basepage |result if on a basepage (|result if on a subpage) (|result if on a subsubpage) (|page=pagename)}}

For example,

{{When on basepage|Basepage|Subpage}} on the page "User:Example" would return: Basepage
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc) it would return: Subpage

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc),

{{When on basepage|Basepage|Subpage|Subsubpage}} would return: Subsubpage

Use an empty parameter to specify no action for a particular type of page.

{{When on basepage|Basepage||Subsubpage}} on "User:Example/page", for example, would return nothing, but would return "Subsubpage" if on "User:Example/page/page", "User:Example/page/page/page", etc (and "Basepage" if on "User:Example").

Handling equals-signs ("=")

އުނިއިތުރު ގެންނަވާ

Use numbered parameters if their values include equals-signs ("="), i.e.

{{When on basepage |1=basepage result (|2=subpage result) (|3=subsubpage result)}}

The page parameter is included for testing/demonstration. For example:

{{When on basepage |(basepage result)|(subpage result)|page=User:Example/test}} Regardless of where the above is placed, it will return: (subpage result)
(because "User:Example/test" is a subpage). The page doesn't have to exist.

If page is left empty (|page=) or undefined, the page where the template is transcluded (i.e.
purge rev-ID : -   b: c: m: n: q: s: t: w: wikt: ?version all messages
$wgMagicWordsEn at CVS Language.php   meta:help:Variable, meta:Global variables
method a method b generates
common namespaces [-2 - 15] / used at all MediaWiki projects
{{ns:-2}} {{ns:Media}}  މީޑިއާ
{{ns:-1}} {{ns:Special}}  ޚާއްސަ
(Main) – MediaWiki:Blanknamespace – ‏(މައި)
{{ns:1}} {{ns:Talk}}  ޚިޔާލު
{{ns:2}} {{ns:User}}  މެމްބަރު
{{ns:3}} {{ns:User_talk}}  މެމްބަރުގެ ވާހަކަ
{{ns:4}} {{ns:Project}}  ވިކިޕީޑިއާ
{{ns:5}} {{ns:Project_talk}}  ވިކިޕީޑިއާ ޚިޔާލު
{{ns:6}} {{ns:Image}}  ފައިލު
{{ns:7}} {{ns:Image_talk}}  ފައިލުގެ ޚިޔާލު
{{ns:8}} {{ns:MediaWiki}}  މީޑިއާވިކީ
{{ns:9}} {{ns:MediaWiki_talk}}  މިޑިއާވިކީ ޚިޔާލު
{{ns:10}} {{ns:Template}}  ފަންވަތް
{{ns:11}} {{ns:Template_talk}}  ފަންވަތުގެ ޚިޔާލު
{{ns:12}} {{ns:Help}}  އެހީ
{{ns:13}} {{ns:Help_talk}}  އެހީގެ ޚިޔާލު
{{ns:14}} {{ns:Category}}  ޤިސްމު
{{ns:15}} {{ns:Category_talk}}  ޤިސްމުގެ ޚިޔާލު
reserved namespaces
{{ns:16}}    
{{ns:17}}    
{{ns:98}}    
{{ns:99}}    
custom namespaces
{{ns:100}}    ނެރު
{{ns:101}}    ނެރު ޚިޔާލު
{{ns:102}}    
{{ns:103}}    
{{ns:104}}    
{{ns:105}}    
{{ns:106}}    
{{ns:107}}    
{{ns:121}}    
{{ns:122}}    
{{ns:127}}    
{{ns:128}}    
{{ns:2147483646}}    
{{ns:2147483647}}    
variables
{{CURRENTDAY}}  30
{{CURRENTDAY2}}  30
{{CURRENTDAYNAME}}  ހޮނިހިރު
{{CURRENTDOW}}  6
{{CURRENTMONTH}}  11
{{CURRENTMONTHABBREV}}  ނޮވެމްބަރ
{{CURRENTMONTHNAME}}  ނޮވެމްބަރު
{{CURRENTMONTHNAMEGEN}}  ނޮވެމްބަރ
{{CURRENTTIME}}  15:17
{{CURRENTWEEK}}  48
{{CURRENTYEAR}}  2024
{{FULLPAGENAME}}  ފަންވަތް:When on basepage
{{FULLPAGENAMEE}}  %DE%8A%DE%A6%DE%82%DE%B0%DE%88%DE%A6%DE%8C%DE%B0:When_on_basepage 1
{{NAMESPACE}}  ފަންވަތް
{{NAMESPACEE}}  %DE%8A%DE%A6%DE%82%DE%B0%DE%88%DE%A6%DE%8C%DE%B0 1
{{NUMBEROFARTICLES}}  3,140
{{NUMBEROFFILES}}  931
{{PAGENAME}}  When on basepage
{{PAGENAMEE}}  When_on_basepage 1
{{SCRIPTPATH}}  /w 1
{{SERVER}}  //dv.wikipedia.org
{{SERVERNAME}}  dv.wikipedia.org
{{SITENAME}}  ވިކިޕީޑިއާ
predefined templates
{{FULLURL:}}  
{{FULLURLE:}}  
{{GRAMMAR:}}  GRAMMAR CVS /languages/
{{INT:}}  
{{LC:}}  
{{LCFIRST:}}  
{{LOCALURL:}}  
{{LOCALURLE:}}  
{{MSG:}}  
{{MSGNW:}}  
{{NS:}}  
{{PLURAL:}}  
{{REVISIONID:}}  
{{REVISIONID}}  -
{{SUBST:}}  
{{UC:}}  
{{UCFIRST:}}  
1 this documentation displays this value LTR (left to right)
 | common reserved custom namespacesvariablespredefined templates
) is used. page also accepts variables, e.g.

{{When on basepage|(basepage result)|(subpage result)|page={{{page|}}} }}

This template detects subpages in all namespaces, including those without the MediaWiki subpage feature enabled.

Alternatives for simpler text

އުނިއިތުރު ގެންނަވާ

A subpage can be detected without using another template, by instead using the title-splitting parser function #titleparts with #ifeq:

{{#ifeq:{{#titleparts:{{PAGENAME}}|1|1}}|{{PAGENAME}}
 | [...code if on a basepage...]
 | [...code if on a subpage...]
}}

For example, many templates can check if the page is a /sandbox version, by the similar markup with #ifeq and #titleparts:

{{#ifeq: {{#titleparts:{{PAGENAME}}|1|1}} | {{PAGENAME}}
| {{documentation}}
| {{template sandbox notice}}
}}

That simple logic works because Template:Template_sandbox_notice also checks the page name for "/sandbox" before displaying the sandbox notice; otherwise, any other subpage would show no extra text. By avoiding a template, and using a single #ifeq, then the processing uses only +2 expansion depth levels, rather than +7 levels, and avoids "wp:exceeded template limits" inside a complex /doc page.

ފަންވަތް:Namespace and pagename-detecting templates