Template:Filter/doc: Difference between revisions

mNo edit summary
No edit summary
Line 1: Line 1:
{{Documentation/Header}}
{{Documentation/Header}}
{{Lua|FilterBuilder}}
{{JS|Gadget-Filter|DataTables}}
{{CSS|Template:Filter/styles}}
{{CSS|Gadget-Filter}}
{{See also|Template:Search}}
Template that creates a row of filters for fiterable tables. To be used in conjuction with {{T|Filter/Header}} and {{T|Filter/Footer}}.
Template that creates filters for fiterable tables. To be used in conjuction with {{T|Filter/Header}} and {{T|Filter/Footer}}.


==Syntax==
==Syntax==
<pre>{{Filter|<1>|<2>|<3>|<4>}}</pre>
<syntaxhighlight lang="wikitext" copy>
This template has up to 4 unnamed parameters:
{{Filter
* <code>1</code> &mdash; Name of data group being filtered. '''''{{Color|New|Required}}'''''
|column =
* <code>2</code> / <code>value</code> &mdash; Comma separated list of possible values for the data group
|all = true
* <code>3</code> / <code>display</code> &mdash; Comma separated list of corresponding displays for the values (e.g., an icon)
|mode =
* <code>4</code> / <code>default</code> &mdash; Comma separated list of default applied filters
|label =
|1 =
|query1 =
|2 =
|query2 =
|3 =
|query3 =
}}
</syntaxhighlight>
* {{F|column}} &ndash; Table column number that will be queried for the filter.
* {{F|mode}} &ndash; Set to:
** {{F|exact}} for an "exact" filter.
** {{F|contains}} for a "contains" filter.
* {{F|label}} &ndash; Text label for filters.
* {{F|((n))}} &ndash; Text displayed on the ''n''-th filter button.
* {{F|query((n))}} &ndash; Text that will be queried upon pressing the ''n''-th filter button


==Example==
==Example==
<pre>
{{Filter/Header|type=neighbors}}
{{Filter/Header|[[creature]]s}}
{{Filter
{{Filter|category|Fish,Insect,Shore-Dweller|Fish,Insect,Shore-Dweller}}
|column = 4
{{Search|dataKey=name|placeholder=Search by creature}}
|all = true
{{Filter|reset}}
|mode = contains
{{Filter/Footer}}
|label = Galaxy:
{| class="wikitable sortable"
|1 = [[File:Hexia Icon.png|30px|link=|class=day-invert-image]]
|-
|query1 = Hexia
! Icon  
|2 = [[File:Taffeh Icon.png|30px|link=|class=day-invert-image]]
! Creature
|query2 = Taffeh
! Category
|3 = [[File:Norvan Icon.png|30px|link=|class=day-invert-image]]
{{#DPL:
|query3 = Norvan
|namespace =
}}
|uses = Template:Creature Infobox
{{Filter
|category = Creatures
|column = 5
|include = {Creature Infobox}:name,{Creature Infobox}:category,{Creature Infobox}:name,{Creature Infobox}:category
|all = true
|format = ,,,
|label = Pronouns:
|secseparators = <tr class="filter-element" data-name=",," data-category=",,"><td>[[File:%PAGE% Icon.png|x30px|link=%PAGE%]]</td><td>[[,,]]</td><td>,,</td></tr>
|1 = He/Him
|ordermethod = sortkey
|2 = She/Her
|count = 40
}}
}}
|}
</pre>
{{Filter/Header|[[creature]]s}}
{{Filter|category|Fish,Insect,Shore-Dweller|Fish,Insect,Shore-Dweller}}
{{Search|dataKey=name|placeholder=Search by creature}}
{{Filter|reset}}
{{Filter/Footer}}
{{Filter/Footer}}
{| class="wikitable sortable"
{{#invoke:Bucket|get|neighbors
|-
|select = page_name, birthday, role, galaxy, pronouns, loves, likes, dislikes
! Icon
|where = {{{where|}}}
! Creature
|filter = {{{filter|}}}
! Category
|order by = page_name
{{#DPL:
 
|namespace =
|format = userformat
|uses = Template:Creature Infobox
|show resultsHeader = false
|category = Creatures
|header = <!--
|include = {Creature Infobox}:name,{Creature Infobox}:category,{Creature Infobox}:name,{Creature Infobox}:category
--><table id="neighbor-list" class="wikitable sortable"><!--
|format = ,,,
--><tr><!--
|secseparators = <tr class="filter-element" data-name=",," data-category=",,"><td>[[File:%PAGE% Icon.png|x30px|link=%PAGE%]]</td><td>[[,,]]</td><td>,,</td></tr>
--><th class="unsortable">Icon</th><!--
|ordermethod = sortkey
--><th>Name</th><!--
|count = 40
--><th>Role</th><!--
--><th>Galaxy</th><!--
--><th>Pronouns</th><!--
--><th>Birthday</th><!--
--><th>Loves</th><!--
--><th>Likes</th><!--
--><th>Dislikes</th><!--
--></tr>
|userformat = <!--
--><tr><!--
--><td>{{Item|size=50|%page_name%|notext=1}}</td><!--
--><td>[[%page_name%]]</td><!--
--><td>%role%</td><!--
--><td><nowiki>{{#if:%galaxy%|{{Item|%galaxy%|invert=Day}}}}</nowiki></td><!--
--><td>%pronouns%</td><!--
--><td>%birthday%</td><!--
--><td><nowiki>{{Item List|%loves%}}</nowiki></td><!--
--><td><nowiki>{{List|%likes%}}</nowiki></td><!--
--><td><nowiki>{{List|%dislikes%}}</nowiki></td><!--
--></tr>
|footer = </table>
}}
}}
|}