Difference between revisions of "Template:Category handler"

From SEG Wiki
Jump to: navigation, search
(More efficient code for the "category" parameter. No change in functionality.)
m (26 revisions from wikipedia:Template:Category handler: imported from WP)
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{#if:
 
{{#if:
 
   {{#ifeq: {{lc: {{{nocat|}}} }} | true
 
   {{#ifeq: {{lc: {{{nocat|}}} }} | true
   | dontcat     <!--"nocat=true", don't categorize-->
+
   | dontcat   <!--"nocat=true", don't categorize-->
 
   }}{{#ifeq: {{lc: {{{categories|}}} }} | no
 
   }}{{#ifeq: {{lc: {{{categories|}}} }} | no
   | dontcat  <!--"categories=no", don't categorize-->
+
   | dontcat
   }}{{#switch: {{lc: {{{category|¬}}} }}
+
  }}{{#switch: {{lc: {{{category2|¬}}} }}
   | no             <!--"category = no"-->
+
  | yes
   |   = dontcat   <!--"category =", defined but empty-->
+
  | ¬  =  <!--Not defined-->
  }}  <!--Else "category = ¬" or not defined or "yes" or other data-->
+
  | #default = dontcat  <!--"category2 = no/'defined but empty'/'anything'"-->
 +
   }}{{#switch: {{lc: {{{subpage|}}} }}
 +
   | no =
 +
    {{basepage subpage
 +
    |
 +
    | dontcat    <!--"subpage=no" and on a subpage-->
 +
    | page = {{{page|}}}  <!--For testing-->
 +
    }}
 +
   | only =  
 +
    {{basepage subpage
 +
    | dontcat   <!--"subpage=only" and not on a subpage-->
 +
    | page = {{{page|}}}  <!--For testing-->
 +
    }}
 +
  }}
  
 
|  <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)-->
 
|  <!--Don't categorise (result was "dontcat" or "dontcatdontcat" and so on)-->
| <!--If "data" is a number, return the corresponding
+
| <!--Check blacklist-->
      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|}}}
+
      |  <!--Skip blacklist check-->
  | 4 = {{{4|}}}
+
      | {{#ifeq: {{lc: {{{category2|}}} }} | yes
  | 5 = {{{5|}}}
+
        |  <!--Skip blacklist check-->
  | 6 = {{{6|}}}
+
        | {{category handler/blacklist| page = {{{page|}}} }}  <!--Check blacklist-->
  | 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-->
 
          }}
 
 
         }}
 
         }}
 
       }}
 
       }}
     | 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 if any namespace parameter is defined-->
 +
    {{#ifeq: h0#384!5nea+w9 | {{{all| {{{main| {{{talk| {{{user| {{{wikipedia| {{{file| {{{mediawiki| {{{template| {{{help| {{{category| {{{portal| {{{book| {{{other| h0#384!5nea+w9 }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}} }}}
 +
    | <!--No namespace parameters fed, basic usage-->
 
       {{namespace detect
 
       {{namespace detect
       | main = {{{main| {{{other| 1 }}} }}}
+
       | main = {{{1|}}}
      | talk = {{{talk| {{{other|}}} }}}
+
       | file = {{{1|}}}
      | user = {{{user| {{{other|}}} }}}
+
       | help = {{{1|}}}
      | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}}
+
       | category = {{{1|}}}
       | file = {{{file| {{{image| {{{other| 1 }}} }}} }}}
+
       | portal = {{{1|}}}
      | mediawiki = {{{mediawiki| {{{other|}}} }}}
+
       | book = {{{1|}}}
      | template = {{{template| {{{other|}}} }}}
 
       | help = {{{help| {{{other| 1 }}} }}}
 
       | category = {{{category| {{{other| 1 }}} }}}
 
       | portal = {{{portal| {{{other| 1 }}} }}}
 
       | other = {{{other|}}} <!--Namespace special or a new namespace-->
 
 
       | page = {{{page|}}}  <!--For testing and demonstration-->
 
       | page = {{{page|}}}  <!--For testing and demonstration-->
 +
      }}
 +
    | <!--Namespace parameters fed, advanced usage.
 +
          If "data" is a number, return the corresponding
 +
          numbered parameter, else return "data".  -->
 +
      {{{all|}}}{{category handler/numbered
 +
      | 1 = {{{1|}}}
 +
      | 2 = {{{2|}}}
 +
      | 3 = {{{3|}}}
 +
      | 4 = {{{4|}}}
 +
      | 5 = {{{5|}}}
 +
      | 6 = {{{6|}}}
 +
      | 7 = {{{7|}}}
 +
      | 8 = {{{8|}}}
 +
      | 9 = {{{9|}}}
 +
      | 10 = {{{10|}}}
 +
      | data =
 +
        <!--Check what namespace, and return the data for it.
 +
            Respecting empty parameters on purpose.  -->
 +
        {{namespace detect
 +
        | main = {{{main| {{{other|}}} }}}
 +
        | talk = {{{talk| {{{other|}}} }}}
 +
        | user = {{{user| {{{other|}}} }}}
 +
        | wikipedia = {{{wikipedia| {{{project| {{{other|}}} }}} }}}
 +
        | file = {{{file| {{{image| {{{other|}}} }}} }}}
 +
        | mediawiki = {{{mediawiki| {{{other|}}} }}}
 +
        | template = {{{template| {{{other|}}} }}}
 +
        | help = {{{help| {{{other|}}} }}}
 +
        | category = {{{category| {{{other|}}} }}}
 +
        | portal = {{{portal| {{{other|}}} }}}
 +
        | book = {{{book| {{{other|}}} }}}
 +
        | other = {{{other|}}}  <!--Namespace special or a new namespace-->
 +
        | page = {{{page|}}}  <!--For testing and demonstration-->
 +
        }}
 
       }}
 
       }}
 
     }}
 
     }}
 
   }}
 
   }}
 
}}<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 13:47, 1 April 2015

[create] Documentation icon Template documentation