Difference between revisions of "Template:If pagename"

From Geohashing
(Adding matching with " /some* ".)
m (14 revisions imported)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!--Check for match with full pagename
+
{{#if:x  <!--Remove surrounding whitespace-->
-->{{#ifeq: {{{ {{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|x }}} | {{{ {{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}| }}}
+
| <!--Check for match with full pagename-->
| {{{ {{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }} }}}  <!--Has data, or is empty but defined-->
+
  {{{ {{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}   <!--Has data, or is empty but defined-->
| <!--Else, are we on a subpage or a basepage?-->
+
  | <!--Check for match with "User:Somepage/+"-->
  {{#if:{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|2}}
+
    {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/+
  | <!--We are on a subpage, check for match with "User:Somepage/"-->
+
    | <!--Else, are we on a subpage or a basepage?-->
    {{#ifeq: {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/|x }}} | {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/| }}}
+
      {{#if:{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|2}}
    | {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/| }}}
+
      | <!--We are on a subpage, check for match with "User:Somepage/*"-->
    | <!--Check for match with "Somepage/"-->
+
        {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/*
      {{#ifeq: {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/|x }}} | {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/| }}}
+
        | <!--Check for match with "Somepage/*"-->
      | {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/| }}}
+
          {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/*
      | <!--Check for match with "/some*"-->
+
          | <!--Check for match with "/something"-->
        {{#ifeq: {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*|x }}} | {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*| }}}
+
            {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}
        | {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*| }}}  <!--"/some*"-->
+
            | <!--Check for match with "/somethin*"-->
        | <!--Check for match with "/something"-->
+
              {{{ /{{lc: {{padleft:|8| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*
        {{#ifeq: {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}|x }}} | {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}| }}}
+
              | <!--Check for match with "/someth*"-->
          | {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}| }}}  <!--Defined-->
+
                {{{ /{{lc: {{padleft:|6| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*
          | {{{subpage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
+
                | <!--Check for match with "/some*"-->
          }}
+
                  {{{ /{{lc: {{padleft:|4| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}# }} }}*   <!--Pad with # so "/a" doesn't match "/aaaa*"-->
        }}
+
                  | {{{subpage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
      }}
+
                  }}}
    }}
+
                }}}
  | <!--We are on a basepage, check for match with "Somepage"-->
+
              }}}
    {{#ifeq: {{{ {{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|x }}} | {{{ {{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}| }}}
+
            }}}
    | {{{ {{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{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}}
 
 
{{documentation}}
 
{{documentation}}
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
</noinclude>

Latest revision as of 14:05, 31 March 2021