Developers

Contents List

Overview

The "contentList" component shows all contents by default. If a user question is selected it then shows only contents related to it.

Usage

How to create this component.

sdk.component('contentList', '#target', options);

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
offset integer 0 Initial number where the list starts showing user questions
length integer 20 Maximum number of shown user questions. Minimum: 1. Max: 100.
categoryId integer 0 Knowledge instance category ID. When a string, it is the category IDs separated by commas.
expandContents boolean true When clicking a content whether to open it or not
sortBy string empty Sort contents by 'creationDate' or 'modificationDate'. Default is non sorting.

Methods

Methods can be used in this component.

Method Description
getContents() Show the full list of Contents of the instance
getPreviousContents Get previous contents (pagination)
getNextContents Get next contents (pagination)
setUserQuestion(uq:integer) Set the user question to get only results related to it
getUserQuestionContents() When a user question is set. Calling this method will show contents related to it
setContents(contents) This method allows to sent to the component a custom contents object and print it like normal contents. The custom contents object has to have the same structure that the result obtained from the Inbenta KM API contents routes
setContentsDataInterceptor(interceptor:function) Set a contents interceptor.
setRelatedDataInterceptor(interceptor:function) Set a related interceptor.

Subcomponent

This component does no have subcomponents.

Events

Events to listen on this component:

Name Params Description
click content: Content object Sent whether a content is clicked
relatedClick integer: Related content id Sent whether a related content is clicked
decisionTreeClick decisionTree: Decision tree object Sent whether a decision tree content is clicked
pagination pagination: Pagination object Sent whether a the pagination button is clicked

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
TITLE_CONTENT_LIST Contents The title for the contents list
USER_QUESTIONS User questions The text for the user questions list title
RELATED_UQ Related user questions The text for user question list title when a content is selected

Example

  • First example: Create a contentList component and show contents from a user question;
var contentList = sdk.component('contentList', '#list');
contentList.setUserQuestion(2);
contentList.getUserQuestionContents();