Template:Filter/doc: Difference between revisions

Creating Template:Filter/doc - Template doesn't work at the moment. Will figure out why later
 
mNo edit summary
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Documentation/Header}}
{{Documentation/Header}}
{{Lua|FilterBuilder}}
{{JS|Gadget-Filter|DataTables}}
{{CSS|Gadget-Filter}}
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==
 
<syntaxhighlight lang="wikitext" copy>
==Usage==
{{Filter
<pre>{{Filter|<1>|<2>|<3>|<4>}}</pre>
|column =
This template has up to 4 unnamed parameters:
|all = true
* <code>1</code> &mdash; Name of data group being filtered. '''''{{Color|New|Required}}'''''
|mode =
* <code>2</code> / <code>value</code> &mdash; Comma separated list of possible values for the data group
|label =
* <code>3</code> / <code>display</code> &mdash; Comma separated list of corresponding displays for the values (e.g., an icon)
|1 =
* <code>4</code> / <code>default</code> &mdash; Comma separated list of default applied filters
|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==
{{Filter/Header|message=Click on the buttons to apply a filter to the list of [[creature]]s.}}
{{Filter/Header|id=neighbor-list|type=neighbors}}
{{Filter|category|Fish,Insects,Shore-Dwellers|Fish,Insects,Shore-Dwellers|}}
{{Filter
{{Filter|reset}}
|column = 4
|all = true
|mode = contains
|label = Galaxy:
|1 = [[File:Hexia Icon.png|30px|link=|class=day-invert-image]]
|query1 = Hexia
|2 = [[File:Taffeh Icon.png|30px|link=|class=day-invert-image]]
|query2 = Taffeh
|3 = [[File:Norvan Icon.png|30px|link=|class=day-invert-image]]
|query3 = Norvan
}}
{{Filter
|column = 5
|all = true
|label = Pronouns:
|1 = He/Him
|2 = She/Her
}}
{{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-search="," 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>
}}
}}
|}