• ପ୍ରଧାନ ପୃଷ୍ଠା
  • ଯାହିତାହି
  • ପାଖାପାଖି
  • ଲଗ-ଇନ
  • ସଜାଣି
  • ଦାନ
  • ଉଇକିପିଡ଼ିଆ ବାବଦରେ
  • ଆମେ ଦାୟୀ ନୋହୁଁ
ଉଇକିପିଡ଼ିଆ

ଛାଞ୍ଚ:When on basepage

  • ଭାଷା
  • ଦେଖିବେ
  • ସମ୍ପାଦନା (Edit)
Template documentation[view] [edit] [history] [purge]

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.

ବିଷୟସୂଚୀ

  • ୧ Usage
    • ୧.୧ Handling equals-signs ("=")
    • ୧.୨ page parameter
  • ୨ Technical note
  • ୩ Alternatives for simpler text
  • ୪ See also

Usage ସମ୍ପାଦନା

{{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)}}

page parameter ସମ୍ପାଦନା

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. {{PAGENAME}}) is used.

page also accepts variables, e.g. {{When on basepage|(basepage result)|(subpage result)|page={{{page|}}} }}

Technical note ସମ୍ପାଦନା

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.

See also ସମ୍ପାଦନା

  • v
  • t
  • e
Namespace and pagename-detecting templates
Namespace
Particular
  • Main other
  • Talk other
  • Book other
  • Category other
  • Draft other
  • File other
    • Is Commons
  • Help other
  • Module other
  • Portal other
  • Template other
  • User other
  • Wikipedia other
  • Single namespace
  • If talkspace of
  • If usertalk 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)
Others
Stub other
Detects whether it is on a page with a stub template or not.
Preview other
Detects whether page is viewed as a preview or not.
  • Wikipedia:Namespace
  • Wikipedia:Page name
  • Magic words
  • ParserFunctions
The above documentation is transcluded from ଛାଞ୍ଚ:When on basepage/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 template.
"https://or.wikipedia.org/w/index.php?title=ଛାଞ୍ଚ:When_on_basepage&oldid=432718"ରୁ ଅଣାଯାଇଅଛି
Last edited on ୪ ଅଗଷ୍ଟ ୨୦୨୧, at ୧୫:୨୫

Languages

    • ak:Nhwɛsode:Basepage subpage
    • العربية
    • مصرى
    • অসমীয়া
    • تۆرکجه
    • भोजपुरी
    • বাংলা
    • Bosanski
    • 閩東語 / Mìng-dĕ̤ng-ngṳ̄
    • کوردی
    • Corsu
    • Cymraeg
    • Dansk
    • Ελληνικά
    • English
    • فارسی
    • Føroyskt
    • गोंयची कोंकणी / Gõychi Konknni
    • ગુજરાતી
    • Gungbe
    • हिन्दी
    • Bahasa Indonesia
    • Ilokano
    • 日本語
    • Jawa
    • Taqbaylit
    • 한국어
    • Kurdî
    • Latina
    • मैथिली
    • Македонски
    • മലയാളം
    • Монгол
    • मराठी
    • Bahasa Melayu
    • မြန်မာဘာသာ
    • Norfuk / Pitkern
    • Português
    • Română
    • Русский
    • संस्कृतम्
    • Scots
    • ၽႃႇသႃႇတႆး
    • Simple English
    • Slovenščina
    • Српски / srpski
    • தமிழ்
    • ತುಳು
    • తెలుగు
    • Тоҷикӣ
    • ไทย
    • Türkçe
    • ChiTumbuka
    • Українська
    • اردو
    • Oʻzbekcha / ўзбекча
    • Tiếng Việt
    • 吴语
    • Yorùbá
    • 中文
    • Bân-lâm-gú
    • 粵語
    • IsiZulu
    ଉଇକିପିଡ଼ିଆ
    • ଏ ପୃଷ୍ଠାଟି ୪ ଅଗଷ୍ଟ ୨୦୨୧ ଦିନ ୧୫:୨୫ ବେଳେ ବଦଳାଯାଇଥିଲା ।
    • ଦର୍ଶାଯାଇନଥିଲେ ସମସ୍ତ ବିଷୟବସ୍ତୁ CC BY-SA 4.0 ରେ ଉପଲବ୍ଧ ।
    • ଗୁମର ନୀତି
    • ଉଇକିପିଡ଼ିଆ ବାବଦରେ
    • ଆମେ ଦାୟୀ ନୋହୁଁ
    • Code of Conduct
    • ଡେଭେଲପରମାନେ
    • ପରିସଂଖ୍ୟାନ
    • କୁକି ବିବରଣୀ
    • ବ୍ୟବହାର ନିୟମାବଳୀ
    • ଡେସ୍କଟପ