Popular

Overview

This component shows popular contents.

Usage

How to create this component.

sdk.component('popular', target:String, options:Object);

Sample

By default, this component looks like this:

Target

This is the HTML component. For example, the "#inbenta" target is:

<div id="inbenta"></div>

Options

Available options to set in this component

Name Type Default Description
categoryId integer 0 KM App category Id
length integer 5 Maximum number of items that may be returned in collection. Minimum:1. Max:100
interval string allTime Time interval to retrieve popular contents. Possible values: allTime, lastWeek and lastDay.

Default options object

{
  categoryId: 0,
  length: 5,
  interval: 'allTime',
  contents: { <more info in subcomponent> }
}

Methods

Methods can be used in this component.

Name Description
setContentsDataInterceptor(interceptor:function) Set a contents interceptor.

Subcomponents

This component contains a subcomponent that can be configured. This component is:

Name Description
contents Component to render each content

Events

Events to listen on this component:

Name Params Description
click content: content object clicked Click on Content
expand content: content object expanded Click on expand Content
rateContent data:Object with rating data Click on content ratings

Tracking

This component calls the API endpoint /tracking/events to register a click event when a user clicks on a content.

Labels

Labels of this component. The default labels of each component can be rewritten in the SDK creation configuration.

Name Default Description
POPULAR_TITLE Popular HTML for popular title
POPULAR_TEXT* Frequently answered questions HTML for popular text. Hidden by CSS.

Examples

Create popular component with related contents.

sdk.component('popular', '#popular', {
    contents: {
        showRelated: true
    }
});