Loading...
Area: Episerver Content Recommendations
Applies to versions: Not applicable

Creating a recommendations block

Recommendations [hide]

This topic describes how to create recommendation blocks on your website.

Note: The following method  addresses implementing recommendations on Episerver sites only.

Prerequisites

The NuGet package adds a new block type model and view for rendering the recommendations.

new-block.jpg

The Content Recommendations block has the following properties:

recoblock.jpg

  • Number of recommendations. How many items to show at a time. You can have as many as you want, but make sure that the design can handle them all.
  • Delivery Widget. Select the recommendations group (flow) for this instance of the recommendations. A list of delivery widgets is set up in the dashboard.
  • Recommendation Template. Enter a Mustache template that defines the repeating pattern for the markup.

    Everything inside the {{#content}} {{/content}} mustache markup is repeated for each recommendation item. You can include additional markup.

    Note: The recommendation template is rendered in the front-end and has no access to the back-end CMS APIs, or content object data. It only knows the JSON that is being returned from the recommendation server.

    You can set up custom metadata for tracking earlier in the template. For example, if you need to display specific category and description content, set it to track in custom tags, and then render those values in the template. 

    To use the custom metadata, use the mustache syntax to traverse the JSON nested property values. For example:

    {{#metadata}}
      {{#tags}}
        {{#og}}
          {{description}}
        {{/og}}
      {{/tags}}
    {{/metadata}}

    Tag-in-idio.jpg

    If you put your markup inside of the nested structure, (if nothing is passed), then the markup will not be rendered. For example,  if no description is passed in the response, then the p tags in the following code will not be rendered either.

    {{#metadata}}
      {{#tags}}
        {{#og}}
          <p>{{description}}</p>
        {{/og}}
      {/tags}}
    {{/metadata}}
Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 09, 2020

Recommendations [hide]