/
Example: Extending facet selections component
Example: Extending facet selections component
Steps to extend
Navigate to the directory of the current active widget template (e.g. Mvc\Views\Hawksearch\Hawksearch.Default.cshtml or the relevant resource package).
Copy the file of the base template or select an existing one.
Edit the file adding or replacing the template override for the selections component:
<script id="vue-hawksearch-selections" type="x-template"> <div v-if="hasSelections" class="hawk-facet-rail__selections"> <h4>{{ $t("You've Selected") }}</h4> <ul class="hawk-selections"> <li v-for="(data, field) in selections" :key="field" class="hawk-selections__category"> <div class="hawk-selections__category-wrapper"> <span class="hawk-selections__category-name">{{ data.Label }}:</span> <ul class="hawk-selections__item-list"> <li v-for="item in data.Items" :key="item" class="hawk-selections__item"> <button v-on:click="clearSelectionItem(field, item)" class="hawk-selections__item-remove"> <x-circle-svg></x-circle-svg> </button> <span :class="itemClass(item)"> <template v-if="getFacetType(field) == 'range'"> {{ rangeLabel(item.Label) }} </template> <template v-else> {{ item.Label }} </template> </span> </li> </ul> </div> <button v-on:click="clearSelectionField(field)" class="hawk-selections__category-remove"> <x-circle-svg></x-circle-svg> </button> </li> <li class="hawk-selections__category"> <button v-on:click="clearAll" class="hawk-btn hawk-btn-primary-outline"> {{ $t("Clear All") }} </button> </li> </ul> <p class="tab-selection">{{ tabSelection.Label }}</p> </div> </script>
Apply the desired structure in this format. There are three handlers: clearAll - for discarding all facets, clearSelectionField - for clearing a single facet and clearSelectionItem for clearing a value from multiple choice facets. Since the tab selection is also a type of facet a tabSelection object is exposed.
Include the file in the project.
Save, build and reload the site.
, multiple selections available,
Related content
Example: Extending suggestion components
Example: Extending suggestion components
More like this
Example: Change component placement
Example: Change component placement
More like this
Example: Enabling content in autocomplete
Example: Enabling content in autocomplete
More like this
Example: Overriding the Popular searches component to add a custom label
Example: Overriding the Popular searches component to add a custom label
More like this
Example: Extending the results set
Example: Extending the results set
More like this
Example: Extending the tab header
Example: Extending the tab header
More like this