For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sortbox

`ff-sortbox` and `ff-sortbox-select` let users change result ordering. They use FactFinder sort options and support native or custom dropdown templates.

Documentation

With the sort box element you can change the order in which products are displayed. There are two kinds of sort boxes:

  • ff-sortbox-select is a native HTML select element.

  • ff-sortbox is a custom-built dropdown element.

Both can be used with or without customization.

Sort box elements are populated with the sortItems portion from the FactFinder search response. Inside the HTML template of the sort box item, you therefore have access to all those data fields (DescribedSortItem).

Native HTML select (ff-sortbox-select)

The ff-sortbox-select element displays a native HTML select element.

<ff-sortbox-select></ff-sortbox-select>
<ff-sortbox-select>
    <option>{{description}}</option>
</ff-sortbox-select>
<ff-sortbox-select>
    <select class="example-class">
        <option>Sort by: {{description}}</option>
    </select>
</ff-sortbox-select>

Rendered HTML

When set up like in the last example above, the rendered HTML could look like this.

<ff-sortbox-select>
    <select class="example-class">
        <option>Sort by: Title A-Z</option>
        <option>Sort by: Title Z-A</option>
        <option>Sort by: Relevance</option>
    </select>
</ff-sortbox-select>

Custom-built dropdown (ff-sortbox)

The ff-sortbox element is a custom-built dropdown. If you do not define any ff-sortbox-item templates, items will default to <ff-sortbox-item>{{description}}</ff-sortbox-item>.

If you do specify ff-sortbox-item templates, you may define an individual template for each item in the sortItems list of the FactFinder response.

FactFinder provides each item with a name and an order field. When you combine them, you get a unique identifier that you can use in the key attribute of the ff-sortbox-item template.

You do not have to specify templates for all sort item types. Only define those that you wish to deviate from the default.

Available keys are as follows:

Key
Description

default.template

This is the fallback template for all options that have no other template defined.

Relevancy.desc

FactFinder always returns an option to sort by relevance.

{name from FactFinder response}.asc

An option as specified in FactFinder in ascending order. (e.g. Price.asc, Title.asc)

{name from FactFinder response}.desc

An option as specified in FactFinder in descending order. (e.g. Discount.desc, Title.desc)

Inside the ff-sortbox-item, you can access the sort option name with {{description}}.

show-selected / show-selected-first

By default, the selected sort option will disappear from the dropdown list and appear in the static container of the element. Setting the show-selected attribute means the selected option remains part of the available options in the dropdown list.

When show-selected is set, you can additionally set show-selected-first to make the selected option appear as the first item in the dropdown. Without show-selected, the setting of show-selected-first has no effect.

collapse-onblur

When the element loses focus, the dropdown will collapse. To make it remain expanded, set the collapse-onblur="false" attribute.

Rendered HTML

When set up like in the example above, the rendered HTML could look like this.

Demo

API

ff-sortbox-select

Properties

Name
Description

items (Array)

The data from FactFinder. Set this through JavaScript only.

Events

Name
Description

dom-updated

This event is triggered when the element has received new data and the template for this element and all sub elements have been punched out.

ff-sortbox

Properties

Name
Description

items (Array)

The data from FactFinder. Set this through JavaScript only.

opened (Boolean)

Determines if the sort box is opened.

show-selected (Boolean)

Determines if the selected sort option also appears in the dropdown.

show-selected-first (Boolean)

Determines if the selected sort option appears first in the dropdown. Requires show-selected.

collapse-onblur (String) Options: "true", "false" (default: "true")

Determines if the dropdown closes automatically after losing focus.

Methods

Name
Description

toggle(expand?: Boolean)

Opens or closes the element, based on its current state.

expand()

Expands the dropdown element.

collapse()

Collapses the dropdown element.

Events

Name
Description

dom-updated

This event is triggered when the element has received new data and the template for this element and all sub elements have been punched out.

ff-sortbox-item

Properties

Name
Description

sortItem (Object)

The data from FactFinder. Available through JavaScript only.

key (String)

Defines the FactFinder sort-item template. Use {sort item 'name'}.{sort item 'order'}, for example Price.asc.

Events

Name
Description

dom-updated

This event is triggered when the element has received new data and the template for this element and all sub elements have been punched out.

Last updated

Was this helpful?