The Content Zone component renders a list of content items or Spotlight products as defined in the Merchandising section of HawkSearch.

Tag

The tag for this component is <hawksearch-content-zone>.

Attributes

Name Value Required
name string Yes

The name attribute corresponds to the Zone property defined in HawkSearch. This is used to differentiate different content areas, allowing you to place content items exactly where you want within your search results page.

Event-Binding Attributes

Name Value
index number

To render a content item, the index attribute must be present with a value corresponding to the item’s index in the items array.

Default Template

The following is the default Handlebars template for this component. To create a custom template, it is recommended to use this as a starting point.

<div class="content-zone">
{{#each items}}
{{#if (eq type "custom")}}
<hawksearch-custom-content index="{{@index}}"></hawksearch-custom-content>
{{/if}}
{{#if (eq type "featured-items")}}
<hawksearch-featured-items-content index="{{@index}}"></hawksearch-featured-items-content>
{{/if}}
{{#if (eq type "image")}}
<hawksearch-image-content index="{{@index}}"></hawksearch-image-content>
{{/if}}
{{#if (eq type "popular-queries")}}
<hawksearch-popular-queries-content index="{{@index}}"></hawksearch-popular-queries-content>
{{/if}}
{{/each}}
</div>

Hierarchy

Properties

bindFromEvent: boolean = true
componentName: keyof HawkSearchComponents = 'content-zone'

Optional instance-level configuration to override the global configuration

The data bound to the Handlebars template.

The data bound to the component.

defaultHtml: string = defaultHtml
handlebars: typeof Handlebars = HawkSearch.handlebars

The Handlebars reference shared by all HawkSearch components.

Accessors

  • get configuration(): undefined | TConfig
  • The optional configuration object for this component.

    Returns undefined | TConfig

  • get rootElement(): ParentNode
  • The root element which should be used for querying any child elements. This resolves to this.shadowRoot if the Shadow DOM is enabled, otherwise this.

    Returns ParentNode

Methods

  • After the component is rendered, this method is called to bind any child components.

    Returns void

  • Returns void

  • Returns void

  • Replaces placeholders in a given string with values from a data object.

    Parameters

    • template: string

      The template string.

    • values: Record<string, string>

      The object containing properties which will be bound to template.

    Returns string

    The template string with all placeholders replaced by the values specified in values.

  • After the component is rendered, this method is called for any additional processing (such as attaching event listeners) which needs to occur.

    Returns void

  • Optional method that can be overwritten to register Handlebars helper functions which can be accessed from the template. For more information, see Custom Helpers.

    Returns void

  • Determines whether the data meets the necessary conditions to perform data binding and render content.

    Returns boolean

    Whether the component should be rendered. If false, the component will have empty contents and be set to display: none;.

  • Type Parameters

    • T

    Parameters

    • name: string
    • data: T

    Returns void