/
Example: Override Results component using Slick.js carousel
Example: Override Results component using Slick.js carousel
Steps to override
Navigate to the directory of the currently active widget template (e.g. Mvc\Views\Hawksearch\Hawksearch.Default.cshtml or the relevant resource package).
Copy the file of the Default template and name it accordingly
Ensure jQuery is loaded on the page:
@Html.Script(ScriptRef.JQuery, "top", false)
Make sure Slick.js resources are loaded:
@Html.Script("https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js", "top", false) @Html.StyleSheet("https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css", "head") @Html.StyleSheet("https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css", "head")
Edit the file adding or replacing the template override for the result item:
<script id="vue-hawksearch-result-listing" type="x-template"> <div> <template> <div class="hawk-results__listing"> <template v-if="!loadingResults && results && results.length"> <div class="slider-area slider" style="width:700px"> <result-item v-for="result in results" :key="result.docid" :result="result"></result-item> </div> </template> </div> </template> </div> </script> <script> window.addEventListener('load', function () { setTimeout(function () { if (HawksearchVue && Object.values(HawksearchVue.widgetInstances).length) { Object.values(HawksearchVue.widgetInstances)[0].$on('resultsupdate', function () { setTimeout(function () { $(".slider-area").slick({ dots: true, infinite: false, slidesToShow: 1, slidesToScroll: 1, }); }, 1) }) } }, 1) }) </script>
Apply the desired structure in this format. All indexed fields are accessible through getField().
Include the file in the project.
Save, build and reload the site.
Open the widget designer for Hawksearch results widget on the designated page and select the newly created template from the select list. Save and publish the page. Configuring Hawksearch results widget
Related articles
, multiple selections available,
Related content
Example: Extending the result items with different layout for products and content
Example: Extending the result items with different layout for products and content
More like this
Example: Extending the results set
Example: Extending the results set
More like this
Example: Overriding the result item component with two column layout using bootstrap classes
Example: Overriding the result item component with two column layout using bootstrap classes
More like this
Extending templates
Extending templates
More like this
Example: Overriding the result item component to include images and links
Example: Overriding the result item component to include images and links
More like this
Customize search results in Vue.js
Customize search results in Vue.js
More like this