Developers

Open Specific Content

Open specific content

You can use the results component to open specific content directly. This is useful when you want to add specific content to a page, for SEO purposes for example.

Open content with a specific ID

Use the method openContentById to open content in the results component. In the following example, content 1 is opened:

  var results = sdk.component('results', '#results');
  results.openContentById(1);

Open content with a specific slug

Use the method openContentBySlug to retrieve content using a slug from the Knowledge instance:

  var results = sdk.component('results', '#results');
  results.openContentBySlug('can-i-change-my-flight');

You can also open content with a URL. Take either the content's id or slug from the URL:

Example:

  • ID: To open the content 1, we can use the URL https://inbenta.com/?faq=1.
  var faq = getQueryString('faqs'); // This function gets the faq parameter from the query string, in this case return 1.
  var results = sdk.component('results', '#results');
  results.openContentById(faq);
  • slug: To open the content What is Inbenta?, we can use the URL https://inbenta.com/what-is-inbenta.
  var slug = getUrlSlug(); // This function gets the slug form the url, in this case return 'what-is-inbenta'.
  var results = sdk.component('results', '#results');
  results.openContentBySlug(slug);