Difference between revisions of "Template:Category handler"

From SEG Wiki
Jump to: navigation, search
(Adding a code comment.)
(Adding support for "category=empty/no/not defined/¬/yes" for backwards compatibility, to ease deployment. Unfortunately bloating the code.)
Line 1: Line 1:
{{#ifeq: {{lc: {{{nocat|}}} }} | true
+
{{#if:
|   <!--"nocat=true", don't categorize-->
+
  {{#ifeq: {{lc: {{{nocat|}}} }} | true
| {{#ifeq: {{lc: {{{categories|}}} }} | no
+
  | dontcat    <!--"nocat=true", don't categorize-->
   |  <!--"categories=no", don't categorize-->
+
  }}{{#ifeq: {{lc: {{{categories|}}} }} | no
   | <!--If "data" is a number, return the corresponding  
+
   | dontcat   <!--"categories=no", don't categorize-->
        numbered parameter, else return "data"-->
+
   }}{{#ifeq: {{{category|¬}}} | ¬
    {{cat handler/numbered
+
  |    <!--"category = ¬" or "category" not defined-->
    | 1 = {{{1|}}}
+
  | {{#if: {{{category|}}}
    | 2 = {{{2|}}}
+
    | {{#ifeq: {{lc: {{{category|}}} }} | no
    | 3 = {{{3|}}}
+
      | dontcat
    | 4 = {{{4|}}}
+
      |  <!--"category = yes" or has other data-->
    | 5 = {{{5|}}}
+
      }}
    | 6 = {{{6|}}}
+
    | dontcat  <!--"category" is defined but empty-->
    | 7 = {{{7|}}}
+
    }}
    | 8 = {{{8|}}}
+
  }}
    | 9 = {{{9|}}}
+
|  <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)-->
    | 10 = {{{10|}}}
+
| <!--If "data" is a number, return the corresponding  
    | data =  
+
      numbered parameter, else return "data"-->
      {{#switch:
+
  {{cat handler/numbered
        {{#ifeq: {{lc: {{{nocat|}}} }} | false
+
  | 1 = {{{1|}}}
        |  <!--"nocat=false", skip blacklist check-->
+
  | 2 = {{{2|}}}
         | {{#ifeq: {{lc: {{{categories|}}} }} | yes
+
  | 3 = {{{3|}}}
           |  <!--"categories=yes", skip blacklist check-->
+
  | 4 = {{{4|}}}
 +
  | 5 = {{{5|}}}
 +
  | 6 = {{{6|}}}
 +
  | 7 = {{{7|}}}
 +
  | 8 = {{{8|}}}
 +
  | 9 = {{{9|}}}
 +
  | 10 = {{{10|}}}
 +
  | data =  
 +
    {{#switch:
 +
      {{#ifeq: {{lc: {{{nocat|}}} }} | false
 +
      |  <!--"nocat=false", skip blacklist check-->
 +
      | {{#ifeq: {{lc: {{{categories|}}} }} | yes
 +
        |  <!--"categories=yes", skip blacklist check-->
 +
         | {{#ifeq: {{lc: {{{category|}}} }} | yes
 +
           |  <!--"category=yes", skip blacklist check-->
 
           | {{cat handler/blacklist| page = {{{page|}}} }}  <!--Check blacklist-->
 
           | {{cat handler/blacklist| page = {{{page|}}} }}  <!--Check blacklist-->
 
           }}
 
           }}
 
         }}
 
         }}
       | hide = <!--Blacklist returned "hide", don't categorize-->
+
       }}
      | #default  =  
+
    | hide = <!--Blacklist returned "hide", don't categorize-->
        <!--Check what namespace, and return the data for it-->
+
    | #default  =  
        <!--Respecting empty parameters on purpose-->
+
      <!--Check what namespace, and return the data for it-->
        {{namespace detect
+
      <!--Respecting empty parameters on purpose-->
        | main = {{{main| {{{other| 1 }}} }}}
+
      {{namespace detect
        | talk = {{{talk| {{{other|}}} }}}
+
      | main = {{{main| {{{other| 1 }}} }}}
        | user = {{{user| {{{other|}}} }}}
+
      | talk = {{{talk| {{{other|}}} }}}
        | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}}
+
      | user = {{{user| {{{other|}}} }}}
        | file = {{{file| {{{image| {{{other| 1 }}} }}} }}}
+
      | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}}
        | mediawiki = {{{mediawiki| {{{other|}}} }}}
+
      | file = {{{file| {{{image| {{{other| 1 }}} }}} }}}
        | template = {{{template| {{{other|}}} }}}
+
      | mediawiki = {{{mediawiki| {{{other|}}} }}}
        | help = {{{help| {{{other| 1 }}} }}}
+
      | template = {{{template| {{{other|}}} }}}
        | category = {{{category| {{{other| 1 }}} }}}
+
      | help = {{{help| {{{other| 1 }}} }}}
        | portal = {{{portal| {{{other| 1 }}} }}}
+
      | category = {{{category| {{{other| 1 }}} }}}
        | other = {{{other|}}}  <!--Namespace special or a new namespace-->
+
      | portal = {{{portal| {{{other| 1 }}} }}}
        | page = {{{page|}}}  <!--For testing and demonstration-->
+
      | other = {{{other|}}}  <!--Namespace special or a new namespace-->
        }}
+
      | page = {{{page|}}}  <!--For testing and demonstration-->
 
       }}
 
       }}
 
     }}
 
     }}

Revision as of 23:32, 16 November 2009

Template:Cat handler/numbered

Template:Pp-template

[create] Documentation icon Template documentation