<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Template%3AWhen_on_basepage%2Fdoc</id>
	<title>Template:When on basepage/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Template%3AWhen_on_basepage%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Template:When_on_basepage/doc&amp;action=history"/>
	<updated>2026-04-07T23:19:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Template:When_on_basepage/doc&amp;diff=15901&amp;oldid=prev</id>
		<title>Caleb Cooper: Created page with &quot;{{Documentation subpage}} &lt;!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see Wikipedia:Wikidata)--&gt;  This is the {{tl|When on b...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Template:When_on_basepage/doc&amp;diff=15901&amp;oldid=prev"/>
		<updated>2020-11-10T11:27:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Documentation subpage}} &amp;lt;!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see &lt;a href=&quot;https://en.wikipedia.org/wiki/Wikidata&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Wikidata&quot;&gt;Wikipedia:Wikidata&lt;/a&gt;)--&amp;gt;  This is the {{tl|When on b...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
&amp;lt;!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the {{tl|When on basepage}} meta-template. It helps other templates detect if they are on a &amp;#039;&amp;#039;&amp;#039;basepage&amp;#039;&amp;#039;&amp;#039; (i.e. a page whose name matches the pattern &amp;quot;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;:&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;quot;) &amp;#039;&amp;#039;&amp;#039;subpage&amp;#039;&amp;#039;&amp;#039; (&amp;quot;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;:&amp;#039;&amp;#039;x&amp;#039;&amp;#039;/&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;quot;) or &amp;#039;&amp;#039;&amp;#039;subsubpage&amp;#039;&amp;#039;&amp;#039; (&amp;quot;&amp;#039;&amp;#039;x&amp;#039;&amp;#039;:&amp;#039;&amp;#039;x&amp;#039;&amp;#039;/&amp;#039;&amp;#039;x&amp;#039;&amp;#039;/&amp;#039;&amp;#039;x&amp;#039;&amp;#039;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
An alternative way to detect whether a page is a subpage is to combine the parser functions &amp;lt;code&amp;gt;#ifeq:&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#titleparts&amp;lt;/code&amp;gt;. See [[#Alternatives for simpler text|Alternatives for simpler text]] below.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
: {{tlx|When on basepage&amp;amp;#32;|&amp;#039;&amp;#039;result if on a basepage&amp;#039;&amp;#039;&amp;amp;#32;(|&amp;#039;&amp;#039;result if on a subpage&amp;#039;&amp;#039;)&amp;amp;#32;(|&amp;#039;&amp;#039;result if on a subsubpage&amp;#039;&amp;#039;)&amp;amp;#32;(|page{{=}}&amp;#039;&amp;#039;pagename&amp;#039;&amp;#039;)}}&lt;br /&gt;
&lt;br /&gt;
For example, {{tlf|When on basepage |Basepage |Subpage}} on the page &amp;quot;User:Example&amp;quot; would return: {{When on basepage|Basepage|Subpage|page=User:Example}}&amp;lt;br/&amp;gt;whilst on &amp;quot;User:Example/page&amp;quot; (or &amp;quot;User:Example/page/page&amp;quot;, &amp;quot;User:Example/page/page/page&amp;quot;, etc.) it would return: {{When on basepage|Basepage|Subpage|page=User:Example/page}}&lt;br /&gt;
&lt;br /&gt;
On a subsubpage such as &amp;quot;User:Example/page/page&amp;quot; (or &amp;quot;User:Example/page/page/page&amp;quot;, etc.), {{nowrap|{{tlf|When on basepage |Basepage |Subpage |Subsubpage}}}} would return: {{When on basepage |Basepage |Subpage |Subsubpage |page=User:Example/page/page}}&lt;br /&gt;
&lt;br /&gt;
Use an empty parameter to specify no action for a particular type of page. {{nowrap|{{tlf|When on basepage |Basepage | |Subsubpage}}}} on &amp;quot;User:Example/page&amp;quot;, for example, would return nothing, but would return &amp;quot;Subsubpage&amp;quot; if on &amp;quot;User:Example/page/page&amp;quot;, &amp;quot;User:Example/page/page/page&amp;quot;, etc. (and &amp;quot;Basepage&amp;quot; if on &amp;quot;User:Example&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===Handling equals-signs (&amp;quot;=&amp;quot;)===&lt;br /&gt;
Use numbered parameters if their values include equals-signs (&amp;quot;=&amp;quot;), i.e.&lt;br /&gt;
: {{tlf|When on basepage&amp;amp;#32;|1{{=}}&amp;#039;&amp;#039;basepage result&amp;#039;&amp;#039; (|2{{=}}&amp;#039;&amp;#039;subpage result&amp;#039;&amp;#039;) (|3{{=}}&amp;#039;&amp;#039;subsubpage result&amp;#039;&amp;#039;)}}&lt;br /&gt;
&lt;br /&gt;
===&amp;#039;&amp;#039;page&amp;#039;&amp;#039; parameter===&lt;br /&gt;
The &amp;#039;&amp;#039;page&amp;#039;&amp;#039; parameter is included for testing/demonstration. For example:&lt;br /&gt;
: {{tlf|When on basepage&amp;amp;#32;|(basepage result) |(subpage result) |page{{=}}User:Example/test}}&lt;br /&gt;
Regardless of where the above is placed, it will return: {{When on basepage|(basepage result)|(subpage result)|page=User:Example/test}}&amp;lt;br/&amp;gt;(because &amp;quot;User:Example/test&amp;quot; is a subpage). The page doesn&amp;#039;t have to exist.&lt;br /&gt;
&lt;br /&gt;
If &amp;#039;&amp;#039;page&amp;#039;&amp;#039; is left empty ({{para|page}}) or undefined, the page where the template is transcluded (i.e. {{tld|PAGENAME}}) is used.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;page&amp;#039;&amp;#039; also accepts variables, e.g. {{nowrap|{{tlf|When on basepage |(basepage result) |(subpage result) |page&amp;lt;nowiki&amp;gt;={{{page|}}}&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp;}}}}&lt;br /&gt;
&lt;br /&gt;
== Technical note ==&lt;br /&gt;
&lt;br /&gt;
This template detects subpages in all namespaces, including those without the [[meta:Link#Subpage feature|MediaWiki subpage feature]] enabled.&lt;br /&gt;
&lt;br /&gt;
== Alternatives for simpler text ==&lt;br /&gt;
&lt;br /&gt;
A subpage can be detected without using another template, by instead using the title-splitting parser function &amp;lt;code&amp;gt;#titleparts&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;#ifeq&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{#ifeq:{{#titleparts:{{PAGENAME}}|1|1}}|{{PAGENAME}}&lt;br /&gt;
 | [...code if on a basepage...]&lt;br /&gt;
 | [...code if on a subpage...]&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For example, many templates can check if the page is a /sandbox version, by the similar markup with &amp;lt;code&amp;gt;#ifeq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;#titleparts&amp;lt;/code&amp;gt;:&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{#ifeq: {{#titleparts:{{PAGENAME}}|1|1}} | {{PAGENAME}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
:: &amp;lt;nowiki&amp;gt; | {{documentation}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
:: &amp;lt;nowiki&amp;gt; | {{template sandbox notice}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
That simple logic works because [[Template:Template sandbox notice]] also checks the page name for &amp;quot;/sandbox&amp;quot; before displaying the sandbox notice; otherwise, any other subpage would show no extra text. By avoiding a template, and using a single &amp;lt;code&amp;gt;#ifeq&amp;lt;/code&amp;gt;, then the processing uses only +2 expansion depth levels, rather than +7 levels, and avoids &amp;quot;[[wp:exceeded template limits]]&amp;quot; inside a complex /doc page.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
{{Namespace and pagename-detecting templates}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
&amp;lt;!--Categories below this line, please; interwikis at Wikidata--&amp;gt;&lt;br /&gt;
[[Category:Pagename manipulation templates]]&lt;br /&gt;
[[Category:Wikipedia metatemplates]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
</feed>