Difference between revisions of "Template:Card query"

From Yugipedia
Jump to: navigation, search
(allow for raw query input by omitting the second unnamed parameter)
(here goes nothing)
Line 1: Line 1:
{{ #vardefine: $query_medium | {{ #switch: {{ lc: {{{medium}}} }}
+
<!-- one day, we won't need to use this variable so much... that day, unfortunately, is not today
 +
-->{{ #vardefine: $query_medium | {{ #switch: {{ lc: {{{medium}}} }}
 
   | ocg | tcg | ocg/tcg | tcg/ocg | official = official
 
   | ocg | tcg | ocg/tcg | tcg/ocg | official = official
 
   | anime = anime
 
   | anime = anime
Line 25: Line 26:
 
     }}
 
     }}
 
   }}
 
   }}
}}{{ #vardefine: $query_query | {{ #var: $query_medium_query }}{{ #var: $query_card_type_query }}{{ #if: {{{2|}}}
+
}}<!-- the actual query the user wants
 +
-->{{ #vardefine: $query_query | {{ #if: {{{2|}}}
 
   | [[{{{1}}}::{{{2}}}]]{{ #if: {{{3|}}} | [[{{{3}}}::{{{4}}}]] }}{{ #if: {{{5|}}} | [[{{{5}}}::{{{6}}}]] }}{{ #if: {{{7|}}} | [[{{{7}}}::{{{8}}}]] }}
 
   | [[{{{1}}}::{{{2}}}]]{{ #if: {{{3|}}} | [[{{{3}}}::{{{4}}}]] }}{{ #if: {{{5|}}} | [[{{{5}}}::{{{6}}}]] }}{{ #if: {{{7|}}} | [[{{{7}}}::{{{8}}}]] }}
 
   | {{{1}}}
 
   | {{{1}}}
 
   }}
 
   }}
 +
}}{{ #vardefine: $query_query_lc | {{ lc: {{ #var: $query_query }} }}
 +
}}<!--
 +
 +
decide which data columns get displayed (this might need a force display parameter for some queries, but we'll try without for now)
 +
#ask seems to ignore empty pipe parameters, so doing it this way saves us many, many possible permutations of full statements
 +
of course, if it allowed using {{!}} for pipes (as it should), this could be simplified further...
 +
 +
-->{{ #vardefine: $query_col_card_type | {{ #if: {{ #pos: {{ #var: $query_query_lc }} | {{!((}}card type:: }} || ?Card type = }}
 +
}}{{ #vardefine: $query_col_attribute | {{ #if: {{ #pos: {{ #var: $query_query_lc }} | {{!((}}attribute:: }} || ?Attribute = }}
 
}}{{ #ifeq: {{ #var: $query_card_type }} | monster
 
}}{{ #ifeq: {{ #var: $query_card_type }} | monster
| {{ #switch: {{ #var: $query_medium }}
+
| {{ #vardefine: $query_col_card_type_m | {{ #switch: {{ #var: $query_medium }} | anime | manga = | #default = {{ #var: $query_col_card_type }} Monster type }}
   | official      = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Card type = Monster type |?Monster type = Monster subtype |?Attribute = [[Attribute]] |?Type = [[Type]] |?Stars string = [[Level]]/[[Rank]] |?ATK string = [[ATK]] |?DEF string = [[DEF]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
   }}{{ #vardefine: $query_col_primary_type | {{ #if: {{ #pos: {{ #var: $query_query_lc }} | {{!((}}primary type:: }} || ?Primary type }}
   | anime | manga = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Primary type |?Secondary type |?Attribute = [[Attribute]] |?Type = [[Type]] |?Stars string = [[Level]]/[[Rank]] |?ATK string = [[ATK]] |?DEF string = [[DEF]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
  }}{{ #vardefine: $query_col_primary_type | {{ #ifeq: {{ #var: $query_medium }} | official || {{ #var: $query_col_primary_type }} }}
   | #default      = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Card type = Monster type |?Primary type |?Monster type = Monster subtype |?Secondary type |?Attribute = [[Attribute]] |?Type = [[Type]] |?Stars string = [[Level]]/[[Rank]] |?ATK string = [[ATK]] |?DEF string = [[DEF]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
   }}{{ #vardefine: $query_col_monster_type | {{ #if: {{ #pos: {{ #var: $query_query_lc }} | {{!((}}monster type:: }} || ?Monster type = Monster subtype }}
 +
  }}{{ #vardefine: $query_col_monster_type | {{ #switch: {{ #var: $query_medium }} | anime | manga = | #default = {{ #var: $query_col_monster_type }} }}
 +
   }}{{ #vardefine: $query_col_secondary_type | {{ #if: {{ #pos: {{ #var: $query_query_lc }} | {{!((}}secondary type:: }} || ?Secondary type }}
 +
  }}{{ #vardefine: $query_col_secondary_type | {{ #ifeq: {{ #var: $query_medium }} | official || {{ #var: $query_col_secondary_type }} }}
 +
  }}{{ #vardefine: $query_col_attribute | {{ #var: $query_col_attribute }} = [[Attribute]]
 +
  }}{{ #vardefine: $query_col_type | ?Type = [[Type]]
 +
  }}{{ #vardefine: $query_col_stars | ?Stars string = [[Level]]/[[Rank]]
 +
  }}{{ #vardefine: $query_col_atk | ?ATK string = [[ATK]]
 +
  }}{{ #vardefine: $query_col_atk | ?DEF string = [[DEF]]
 
   }}
 
   }}
| {{ #switch: {{ #var: $query_medium }}
+
| {{ #vardefine: $query_col_attribute | {{ #switch: {{ #var: $query_medium }} | anime | manga = | #default = {{ #var: $query_col_attribute }} {{ #ifeq: {{ #var: $query_medium }} | official | = [[Card type]] }} }}
  | official      = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Attribute = [[Card type]] |?S/T Class = [[Property]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
  }}{{ #vardefine: $query_col_card_type_st | {{ #ifeq: {{ #var: $query_medium }} | official || {{ #var: $query_col_card_type }} [[Card type]] }}
   | anime | manga = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Card type = [[Card type]] |?Property = [[Property]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
   }}{{ #vardefine: $query_col_st_class | {{ #switch: {{ #var: $query_medium }} | anime | manga = | #default = ?S/T Class {{ #ifeq: {{ #var: $query_medium }} | official | = [[Property]] }} }}
   | #default      = {{ #ask: {{ #var: $query_query }} |?Japanese name |?Attribute |?Card type = [[Card type]] |?S/T Class |?Property = [[Property]] | headers = plain | class = sortable wikitable smwtable card-list }}
+
   }}{{ #vardefine: $query_col_property | {{ #ifeq: {{ #var: $query_medium }} | official || ?Property = [[Property]] }}
 
   }}
 
   }}
 +
}}<!--
 +
 +
finally, we get to the actual query
 +
 +
-->{{ #ask: {{ #var: $query_medium_query }}{{ #var: $query_card_type_query }}{{ #var: $query_query }}
 +
  |?Japanese name
 +
  |{{ #var: $query_col_card_type_m }}
 +
  |{{ #var: $query_col_primary_type }}
 +
  |{{ #var: $query_col_monster_type }}
 +
  |{{ #var: $query_col_secondary_type }}
 +
  |{{ #var: $query_col_attribute }}
 +
  |{{ #var: $query_col_card_type_st }}
 +
  |{{ #var: $query_col_type }}
 +
  |{{ #var: $query_col_stars }}
 +
  |{{ #var: $query_col_atk }}
 +
  |{{ #var: $query_col_def }}
 +
  |{{ #var: $query_col_st_class }}
 +
  |{{ #var: $query_col_property }}
 +
  | headers = plain
 +
  | class = sortable wikitable smwtable card-list
 
}}<noinclude>{{Documentation}}</noinclude>
 
}}<noinclude>{{Documentation}}</noinclude>

Revision as of 13:12, 27 February 2016

<ul><li>The part "{{{1}}}" of the query was not understood.Results might not be as expected.</li> <!--br--><li>Some subquery has no valid condition.</li></ul>