Modules / Query loops & dynamic data

Query filter: collapsible sub-terms

Filter: collapsible sub-terms

Fold the sub-terms of a hierarchical Checkbox filter under their parent. Each parent gets a toggle button (a small chevron unless you choose an icon), and its children stay hidden until a visitor opens it.

#16 of 39 modules by votes

  • On by default
  • Needs Bricks 2.4 or newer
  • Tested with Bricks 2.4.3
Recording: someone ticks Collapsible sub-terms on a category filter; on the live page, Kiln Studio pottery opens to Mugs and Tableware, and Mugs opens to Short and Tall.Recorded in Bricks 2.4.3

How to use it

  1. Select a Checkbox filter and turn on its hierarchical option.
  2. Tick Collapsible sub-terms (Kiln).
  3. Open the page. Each term that has children shows a toggle. Click it to show or hide the sub-terms.
  4. Optional: choose how the groups start, allow one open group at a time, and style the toggle (see below).

Options (shown once Collapsible sub-terms (Kiln) is ticked)

  • Initial state: Closed, except groups with an active term (the default), All closed or All open. The visitor's own clicks win over this while they stay on the page.
  • One group open at a time: when a visitor opens a group, Kiln closes the other open groups under the same parent. It acts on clicks, so with All open every group still starts open.
  • Toggle icon: any icon from Bricks' icon picker, such as a plus. Empty keeps the small chevron.
  • Toggle position: after the label (the default) or before it. Before it, rows without sub-terms move in by the toggle's width so the labels line up.
  • Toggle size, Toggle color and Toggle color when open. Like other Bricks style fields, they take breakpoints and the hover state.
  • Icon rotation when open: degrees, 180 by default. Set 0 for an icon that shouldn't rotate, or 45 to turn a plus into a cross.

For the indent of child terms, use Bricks' own Indent: Gap and Indent: Prefix controls on the filter.

Where it appears in Bricks

Checkbox filter element, Content tab: Collapsible sub-terms (Kiln), right after the hierarchical option, and the options above directly under it. They show only while the filter is hierarchical and Limit options is empty.

How it works

  • Folding works at any depth. A sub-term with children of its own gets its own toggle.
  • By default a group that contains a ticked term starts open. If the visitor closes it, it stays closed.
  • When Bricks refreshes the filter by AJAX, Kiln restores which groups were open.
  • Each toggle is a button with a label such as "Show sub-terms: Shoes" or "Hide sub-terms: Shoes", so screen readers announce which term it controls. The button also reports whether the group is open.
  • A parent that Bricks marks as empty (no results) gets no toggle.

Limits

  • It does not work together with Limit options (Bricks' Show more). Both hide rows, so the control is hidden while Limit options has a value.
  • Folding applies on the front end only. The builder canvas shows every row.
  • Without JavaScript, every row shows.
  • The script and stylesheet load only on pages with a filter that uses the option.

Settings

None on the Kiln page. The options sit on each Checkbox filter. Turn the module on in Bricks > Kiln (it is on by default).

Requirements

Bricks 2.4 or newer.