Template:When on basepage

E tswa ho Wikipedia


This is the Template:Tl 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[fetola mohloli]

Template:Tlx

For example, Template:Tlf on the page "User:Example" would return:

This is the Template:Tl 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[fetola mohloli]

Template:Tlx

For example, Template:Tlf on the page "User:Example" would return: Template loop detected: Template:When on basepage
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc.) it would return: Template loop detected: Template:When on basepage

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc.), Template:Tlf would return: Template loop detected: Template:When on basepage

Use an empty parameter to specify no action for a particular type of page. Template:Tlf 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 ("=")[fetola mohloli]

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

Template:Tlf

page parameter[fetola mohloli]

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

Template:Tlf

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

If page is left empty (Template:Para) or undefined, the page where the template is transcluded (i.e. Template:Tld) is used.

page also accepts variables, e.g. Template:Tlf

Technical note[fetola mohloli]

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

Alternatives for simpler text[fetola mohloli]

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[fetola mohloli]

Template:Namespace and pagename-detecting templates
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc.) it would return:

This is the Template:Tl 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[fetola mohloli]

Template:Tlx

For example, Template:Tlf on the page "User:Example" would return: Template loop detected: Template:When on basepage
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc.) it would return: Template loop detected: Template:When on basepage

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc.), Template:Tlf would return: Template loop detected: Template:When on basepage

Use an empty parameter to specify no action for a particular type of page. Template:Tlf 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 ("=")[fetola mohloli]

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

Template:Tlf

page parameter[fetola mohloli]

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

Template:Tlf

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

If page is left empty (Template:Para) or undefined, the page where the template is transcluded (i.e. Template:Tld) is used.

page also accepts variables, e.g. Template:Tlf

Technical note[fetola mohloli]

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

Alternatives for simpler text[fetola mohloli]

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[fetola mohloli]

Template:Namespace and pagename-detecting templates

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc.), Template:Tlf would return:

This is the Template:Tl 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[fetola mohloli]

Template:Tlx

For example, Template:Tlf on the page "User:Example" would return: Template loop detected: Template:When on basepage
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc.) it would return: Template loop detected: Template:When on basepage

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc.), Template:Tlf would return: Template loop detected: Template:When on basepage

Use an empty parameter to specify no action for a particular type of page. Template:Tlf 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 ("=")[fetola mohloli]

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

Template:Tlf

page parameter[fetola mohloli]

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

Template:Tlf

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

If page is left empty (Template:Para) or undefined, the page where the template is transcluded (i.e. Template:Tld) is used.

page also accepts variables, e.g. Template:Tlf

Technical note[fetola mohloli]

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

Alternatives for simpler text[fetola mohloli]

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[fetola mohloli]

Template:Namespace and pagename-detecting templates

Use an empty parameter to specify no action for a particular type of page. Template:Tlf 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 ("=")[fetola mohloli]

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

Template:Tlf

page parameter[fetola mohloli]

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

Template:Tlf

Regardless of where the above is placed, it will return:

This is the Template:Tl 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[fetola mohloli]

Template:Tlx

For example, Template:Tlf on the page "User:Example" would return: Template loop detected: Template:When on basepage
whilst on "User:Example/page" (or "User:Example/page/page", "User:Example/page/page/page", etc.) it would return: Template loop detected: Template:When on basepage

On a subsubpage such as "User:Example/page/page" (or "User:Example/page/page/page", etc.), Template:Tlf would return: Template loop detected: Template:When on basepage

Use an empty parameter to specify no action for a particular type of page. Template:Tlf 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 ("=")[fetola mohloli]

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

Template:Tlf

page parameter[fetola mohloli]

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

Template:Tlf

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

If page is left empty (Template:Para) or undefined, the page where the template is transcluded (i.e. Template:Tld) is used.

page also accepts variables, e.g. Template:Tlf

Technical note[fetola mohloli]

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

Alternatives for simpler text[fetola mohloli]

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[fetola mohloli]

Template:Namespace and pagename-detecting templates
(because "User:Example/test" is a subpage). The page doesn't have to exist.

If page is left empty (Template:Para) or undefined, the page where the template is transcluded (i.e. Template:Tld) is used.

page also accepts variables, e.g. Template:Tlf

Technical note[fetola mohloli]

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

Alternatives for simpler text[fetola mohloli]

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[fetola mohloli]

Template:Namespace and pagename-detecting templates