Example: Extending result item component with date fields

Steps to extend

  1. Navigate to the directory of the currently active widget template (e.g. Mvc\Views\Hawksearch\Hawksearch.Default.cshtml or the relevant resource package).

  2. Copy the file of the base template and name it accordingly (Hawksearch.CustomDateFormat.cshtml for example).

  3. Edit the file adding or replacing the template override for the result item. Make sure to parse the date in the format from the search request-response. Additional information on date parsing formats can be found here.

    <script id="vue-hawksearch-result-item" type="x-template"> <div> <p>{{ moment(getField('date'), 'YYYY-MM-DD').format('DD, M YYYY') }}</p> </div> </script>
  4. Include the file in the project.

  5. Save, build and reload the site.

  6. 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