Template:DropdownFilter

Template page
See also: Template:FilterByGame.

This template is meant to make it easy to create dropdowns that let the user filter items by a set of tags ("options").

Usage

All fields are mandatory.

{{DropdownFilter
 | dropdownWrapperID = should be unique, cannot have spaces
 | dropdownName = should be unique and different from dropdownWrapperID, cannot have spaces
 | attributeName = e.g. "game-data"; cannot have spaces; the name of the HTML attribute that specifies which "tags" each element has
 | nameOfElementToFilter = e.g. "filter-element"; cannot have spaces; the HTML class that identifies which elements should be filtered by this dropdown
 | options = {{DropdownFilter/Option|BBCT}}, {{DropdownFilter/Option|BBCS}}
             A list of Template:DropdownFilter/Options, which must be split by commas.
             The last one in the list cannot have a comma after it.
             The options will appear in this order in the dropdown.
}}
{{DropdownFilter
 | dropdownWrapperID = 
 | dropdownName = 
 | attributeName = 
 | nameOfElementToFilter = 
 | options = {{DropdownFilter/Option|BBCT}}, {{DropdownFilter/Option|BBCS}}
}}

Make sure that dropdownWrapperID and dropdownID are different and unique, or else nothing will happen when options are selected in the dropdown.

Technical Reference

The JSON format for a dropdown looks like this:

{
  "divID":"dropdownWrapperID",
  "name":"dropdownName ",
  "attribute":"attributeName",
  "applyToElementsWithThisClass":"elementsToFilter",
  "options":
    [ 
        ["dropdown option 1", "disabled:false if empty"],
        ["BBCT", ""],
    ]
}