Template:When on basepage/doc: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Davidgothberg
Starting out this documentation. Intermediate save.
 
meta>Davidgothberg
Adding sections "Demospace" and "Technical details".
Line 24: Line 24:
}}
}}


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


:{{basepage subpage
:{{basepage subpage
Line 60: Line 60:
}}
}}
</pre>
</pre>
The code above will render nothing when on "User:Example/test/test" or lower, but will return this when on "User:Example/test":


:{{basepage subpage
:{{basepage subpage
Line 65: Line 67:
| Subpage text
| Subpage text
|  
|  
| demospace = subsubpage
| demospace = subpage
}}
 
=== Demospace ===
 
For testing and demonstration purposes this template can take a parameter named '''demospace'''.
 
* If it has the value '''basepage''' it returns the basepage text.
* It if has the value '''subpage''' it returns the subpage text.
* It if has the value '''subsubpage''' it returns the subsubpage text if there is one, otherwise it returns the subpage text.
* If the parameter is empty or undefined, the actual page type determines the result.
 
Like this:
 
<pre>
{{basepage subpage
| Basepage text
| Subpage text
| demospace = subpage
}}
}}
</pre>


The code above will render nothing when on "User:Example/test/test" or lower, but will return this when on "User:Example/test":
No matter on what kind of page the code above is used it will return this:


:{{basepage subpage
:{{basepage subpage
| Basepage text
| Basepage text
| Subpage text
| Subpage text
|
| demospace = subpage
| demospace = subpage
}}
}}


You can make it so your template also understands the '''demospace''' parameter. That means you can demonstrate the different appearances of your template in the documentation for your template. Then do like this:
<pre>
{{basepage subpage
| Basepage text
| Subpage text
| demospace = {{{demospace|}}}
}}
</pre>
=== Technical details ===


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 ===
=== See also ===

Revision as of 00:41, 4 November 2009

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

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

Usage

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:

Subpage 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:

Subpage 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

Demospace

For testing and demonstration purposes this template can take a parameter named demospace.

  • If it has the value basepage it returns the basepage text.
  • It if has the value subpage it returns the subpage text.
  • It if has the value subsubpage it returns the subsubpage text if there is one, otherwise it returns the subpage text.
  • If the parameter is empty or undefined, the actual page type determines the result.

Like this:

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

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

Subpage text

You can make it so your template also understands the demospace 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
| demospace = {{{demospace|}}}
}}

Technical details

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