{% if selectedIds is not defined %} {% set selectedIds = [] %} {% endif %} {# Handle original ids param which is from the initial page load #} {% if not sprig.isRequest %} {% set selectedIds = _originalIds %} {% endif %} {# Grab the ids from parent context #} {% if selectedIds[_fieldHandle] is defined and selectedIds[_fieldHandle] is not empty %} {% set selectedIds = selectedIds[_fieldHandle] %} {% endif %} {# Convert to array #} {% if selectedIds is not iterable %} {% set selectedIds = selectedIds|split(',') %} {% endif %} {# Filter out duplicates and empties #} {% set selectedIds = selectedIds|filter|unique %} {# Process the removed ID if there is one #} {% if removedId is defined %} {% set removedCat = craft.categories.id(removedId).one() %} {% set childIds = removedCat.descendants.ids() %} {% set filterIds = childIds|push(removedCat.id) %} {% set selectedIds = selectedIds|filter((v, k) => v not in filterIds) %} {% endif %} {# Enforce branch limit etc #} {# TODO: multi-site #} {% set selectedCats = craft.categories.id(selectedIds).anyStatus().all() %} {% set selectedCats = market.prepStructuredElementsForField(selectedCats, _branchLimit) %} {% set preppedSelectedIds = selectedCats|map(c => c.id) %} {% set limitError = false %} {% if selectedIds|length > preppedSelectedIds|length %} {% set limitError = true %} {% endif %} {% set selectedIds = preppedSelectedIds %} {# Run the queries for the actual display of the index #} {% set group = craft.app.getCategories().getGroupByUid(_groupUid) %} {% set query = query ?? '' %} {# TODO: multi-site #} {% set categoriesQuery = craft.categories .groupId(group.id) .limit(null) .search(query) %} {% set categories = categoriesQuery.all() %} {# Panel middle #}
We couldn’t find anything for “{{ query }}”, try being less specific or using different keywords.
Limit reached
Please deselect some categories before adding more