Difference between revisions of "Template:When pagename is"

From MINR.ORG WIKI
(Fixing matching order for "/something" and "/some*".)
(Using the parameter pipe-trick instead of #ifeq, to detect defined parameters. Much more efficient, and shorter and clearer code. Then it needs the surrounding whitespace stripping.)
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?-->
+
  | <!--Else, are we on a subpage or a basepage?-->
−
  {{#if:{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|2}}
+
    {{#if:{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|2}}
−
  | <!--We are on a subpage, check for match with "User:Somepage/"-->
+
    | <!--We are on a subpage, check for match with "User:Somepage/"-->
−
    {{#ifeq: {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/|x }}} | {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/| }}}
+
      {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/
−
    | {{{ {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|1|1}}/| }}}
+
      | <!--Check for match with "Somepage/"-->
−
    | <!--Check for match with "Somepage/"-->
+
        {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/
−
      {{#ifeq: {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/|x }}} | {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/| }}}
+
        | <!--Check for match with "/something"-->
−
      | {{{ {{#titleparts:{{#if:{{{page|}}}| {{PAGENAME:{{{page|}}}}} | {{PAGENAME}} }}|1|1}}/| }}}
+
          {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}
−
      | <!--Check for match with "/something"-->
+
          | <!--Check for match with "/some*"-->
−
        {{#ifeq: {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}|x }}} | {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}| }}}
+
            {{{ /{{lc: {{padleft:|4| {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*
−
        | {{{ /{{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}}| }}}  <!--Defined-->
+
            | {{{subpage| {{{other|}}} }}}  <!--Respecting empty parameter on purpose-->
−
        | <!--Check for match with "/some*"-->
+
            }}}
−
        {{#ifeq: {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*|x }}} | {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*| }}}
+
           }}}
−
          | {{{ /{{padleft:|4| {{lc: {{#titleparts:{{#if:{{{page|}}}| {{{page|}}} | {{FULLPAGENAME}} }}|0|-1}} }} }}*| }}}  <!--"/some*"-->
+
         }}}
−
          | {{{subpage| {{{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-->
−
     }}
+
      }}}
−
  | <!--We are on a basepage, check for match with "Somepage"-->
+
    }}  <!--End if, are we on a subpage or a basepage?-->
−
    {{#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-->
 
−
    }}
 
−
  }}
 
 
}}<noinclude>
 
}}<noinclude>
  

Revision as of 13:29, 6 November 2009


Template:Pp-template

Template documentation[create]