Generates a filter block: a field of the Filters form (the search and filters visitors use on a loop grid) written by you, and its test.
$ mix elementorex.gen.filter PriceRanges
Creates lib/my_app_web/blocks/price_ranges.ex (module
MyAppWeb.Blocks.PriceRanges) and its test: a list of ranges written in the
editor (Under 20.000, 20.000 to 50.000…) that visitors pick with radio
buttons. Change its markup at will; what makes it a filter is the name and
value of its inputs (see ElementorexCms.Filters):
filter_name(assigns, @field)-catalog[price], one valuefilter_name(assigns, [@field, ""])-catalog[price][], severalfilter_name(assigns, [@field, "min"])- a bound of a range- values like
"20000..50000"are ranges of number and date fields filter_value/2,filter_checked?/3andfilter_options/2read the visitor's choice and the values of the field
Logic that a field cannot express (In stock is stock > 0) goes in the
source: see filters: in ElementorexCms.Source.Ecto.
Register it afterwards:
config :elementorex_cms, blocks: [MyAppWeb.Blocks.PriceRanges]Options
--type,--label,--icon- stored type, name in the palette and its Heroicon (defaultfunnel)--namespace- defaultMyAppWeb.Blocks--no-test,--force