Difference between revisions of "Template:If pagename"

From Self-sufficiency
Jump to: navigation, search
m (1 revision)
(Starting out this pagename-detection meta-template.)
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{#if:x  <!--Remove surrounding whitespace-->
+
<!--Check for match with full pagename
| <!--Check for match with full pagename-->
+
-->{{#ifeq: {{{ {{FULLPAGENAME}}|x }}} | {{{ {{FULLPAGENAME}}| }}}
  {{{ {{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}  <!--Has data, or is empty but defined-->
+
| {{{ {{FULLPAGENAME}} }}}  <!--Has data, or is empty but defined-->
  | <!--Check for match with "User:Somepage/+"-->
+
| <!--Else, are we on a subpage or a basepage?-->
    {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/+
+
  {{#if:{{#titleparts:{{FULLPAGENAME}}|0|2}}
    | <!--Else, are we on a subpage or a basepage?-->
+
  | <!--We are on a subpage, check for match with "User:Somepage/"-->
      {{#if:{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|2}}
+
    {{#ifeq: {{{ {{#titleparts:{{FULLPAGENAME}}|1|1}}/|x }}} | {{{ {{#titleparts:{{FULLPAGENAME}}|1|1}}/| }}}
      | <!--We are on a subpage, check for match with "User:Somepage/*"-->
+
    | {{{ {{#titleparts:{{FULLPAGENAME}}|1|1}}/| }}}
        {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/*
+
    | <!--Check for match with "Somepage/"-->
        | <!--Check for match with "Somepage/*"-->
+
      {{#ifeq: {{{ {{#titleparts:{{PAGENAME}}|1|1}}/|x }}} | {{{ {{#titleparts:{{PAGENAME}}|1|1}}/| }}}
          {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/*
+
      | {{{ {{#titleparts:{{PAGENAME}}|1|1}}/| }}}
          | <!--Check for match with "/something"-->
+
      | <!--Check for match with "/something"-->
            {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}
+
        {{#ifeq: {{{ /{{#titleparts:{{FULLPAGENAME}}|0|2}}|x }}} | {{{ /{{#titleparts:{{FULLPAGENAME}}|0|2}}| }}}
            | <!--Check for match with "/somethin*"-->
+
        | {{{ /{{#titleparts:{{FULLPAGENAME}}|0|2}}| }}}  <!--Defined-->
              {{{ /{{lc: {{padleft:|8| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*
+
        | {{{subpage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
              | <!--Check for match with "/someth*"-->
+
        }}
                {{{ /{{lc: {{padleft:|6| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*
+
      }}
                | <!--Check for match with "/some*"-->
+
    }}
                  {{{ /{{lc: {{padleft:|4| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*   <!--Pad with # so "/a" doesn't match "/aaaa*"-->
+
  | <!--We are on a basepage, check for match with "Somepage"-->
                  | {{{subpage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
+
    {{#ifeq: {{{ {{PAGENAME}}|x }}} | {{{ {{PAGENAME}}| }}}
                  }}}
+
    | {{{ {{PAGENAME}} }}}  <!--Defined-->
                }}}
+
    | {{{basepage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
              }}}
+
     }}
            }}}
+
   }}
          }}}
+
        }}}
+
      | <!--We are on a basepage, check for match with "Somepage"-->
+
        {{{ {{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}
+
        | {{{basepage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
+
        }}}
+
      }}  <!--End if, are we on a subpage or a basepage?-->
+
     }}}
+
   }}}
+
 
}}<noinclude>
 
}}<noinclude>
  
{{pp-template}}
+
<!-- {{pp-template}} -->
 
{{documentation}}
 
{{documentation}}
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
</noinclude>

Revision as of 03:30, 5 November 2009