Template:Basepage subpage/doc

Da Comunica.
Versione delle 22:56, 4 nov 2012, autore: Admin (Discussione | contributi)
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

{{#ifeq: basepage subpage/doc | doc

 | 

{{

   #ifeq: show | show
   | {{
 {{#switch:
 {{#if: 
   | 
   | {{#if: 
     | 
       {{#ifeq:|
       | talk
       |  
       }}
     | 
       {{#ifeq:template|discussioni template
       | talk
       | template 
       }}
     }}
   }}

| main | = ambox | talk = tmbox | user = ombox | wikipedia = ombox | file | image = imbox | mediawiki = ombox | template = ombox | help = ombox | category = cmbox | portal = ombox | book = ombox | other | #default = ombox

}} | type = notice | image = 40px | imageright = | class = | style = | textstyle = | text = This is a documentation subpage for Template:Basepage subpage/doc.
It contains usage information, categories, interlanguage links and other content that is not part of the original {{ #if: | {{{text2}}} | {{ #if: | {{{text1}}} | {{ #ifeq: Template | Utente | template template page | {{ #if: Template |template page|article}}}}}}}}. | small = | smallimage = | smallimageright = | smalltext = | subst = | date = | name = }}

   }}{{
   #if: 
   | 
   | {{#ifexist:Template:Basepage subpage/doc|[[Category:{{
     #switch: Template
     | Template  = Template
     | User      = User
     | #default  = Wikipedia
   }} documentation pages]]|}}
 }}

| }} {{#ifeq:|yes

| {{#ifeq:{{#if:| {{{smallimage}}} | }}|none | | }}

{{#if:{{#if: | {{{smallimageright}}} | }} | {{#ifeq:{{#if: | {{{smallimageright}}} | }}|none

 | 
|
 }}

}}

{{#switch:content

| | speedy | delete | content | style | move | protection | notice =

| #default =
This message box is using an invalid "type=content" parameter and needs fixing.

}}

| {{#ifeq:|none | | }}

{{#if: | {{#ifeq:|none

 | 
|
 }}

}}

{{#switch:content

| | speedy | delete | content | style | move | protection | notice =

| #default =
This message box is using an invalid "type=content" parameter and needs fixing.

}} }}

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

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

Indice

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 shall return this:

{{#switch:
 {{#if:User:Example
 | {{#if:{{#titleparts:User:Example|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:User:Example|0|2}}
     | subpage
     | basepage
     }}
   }}
 | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|2}}
     | subpage
     | basepage
     }}
   }}
 }}

| basepage = Basepage text

| subpage = Subpage text

| subsubpage = 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:

{{#switch:
 {{#if:User:Example/test/test
 | {{#if:{{#titleparts:User:Example/test/test|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:User:Example/test/test|0|2}}
     | subpage
     | basepage
     }}
   }}
 | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|2}}
     | subpage
     | basepage
     }}
   }}
 }}

| basepage = Basepage text

| subpage = Subpage text

| subsubpage = 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:

{{#switch:
 {{#if:User:Example/test/test
 | {{#if:{{#titleparts:User:Example/test/test|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:User:Example/test/test|0|2}}
     | subpage
     | basepage
     }}
   }}
 | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|2}}
     | subpage
     | basepage
     }}
   }}
 }}

| basepage = Basepage text

| subpage = Subpage text

| subsubpage = Subsubpage 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":

{{#switch:
 {{#if:User:Example/test
 | {{#if:{{#titleparts:User:Example/test|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:User:Example/test|0|2}}
     | subpage
     | basepage
     }}
   }}
 | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|2}}
     | subpage
     | basepage
     }}
   }}
 }}

| basepage = Basepage text

| subpage = Subpage text

| subsubpage =

}}

The "page" parameter

For testing and demonstration purposes this template can take a parameter named page. Like this:

{{basepage subpage
| Basepage text
| Subpage text
| page = User:Example/test
}}

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

{{#switch:
 {{#if:User:Example/test
 | {{#if:{{#titleparts:User:Example/test|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:User:Example/test|0|2}}
     | subpage
     | basepage
     }}
   }}
 | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|3}}
   | subsubpage    
   | {{#if:{{#titleparts:Template:Basepage subpage/doc|0|2}}
     | subpage
     | basepage
     }}
   }}
 }}

| basepage = Basepage text

| subpage = Subpage text

| subsubpage = Subpage text

}}

The page parameter makes this template behave exactly as if on that page. Thus, if a subsubpagename like "User:Example/test/test" is fed, then it returns the subsubpage text if there is one, otherwise it returns the subpage text.

The pagename doesn't have to be an existing page.

If the parameter is empty or undefined, the name of the current page determines the result.

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

Technical details

Templates have a problem to handle parameter data that contains equal signs "=". But that is easily solved by using numbered parameters. Like this:

{{basepage subpage
| 1 = Basepage text
| 2 = Subpage text
| 3 = Subsubpage text
| page = {{{page|}}}
}}

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

Pagename-handling and detection templates:

  • {{basepage subpage}} – For detecting if on a basepage, subpage or subsubpage.
  • {{pgn}} – Can take apart and put together pagenames in several ways.
  • {{if pagename}} – For pattern matching on the pagename.
  • {{if pagename multi}} – For pattern matching on the pagename, has input reuse.
  • {{IP-user other}} – For detecting IP-user pages.
  • {{IP-talk}} - Return: 1) IP user talk page 2) registered user talk page 3) not user talk page.

Easy to use namespace-detection templates:

More complex namespace-detection templates:

Technical stuff:


Strumenti personali
Namespace
Varianti
Azioni
Navigazione
Comunicall
Rete Intelligente
TLC Software
Miscellanea
Varie
Strumenti