Menu
Content Services

News List Widget

List recent news articles headlines from a configurable list of categories.

Installation

script

Example

                              window.dtn.news.createNewsListWidget({
 


                                
});
                              
                            

Types

NewsCategories

type NewsCategories =
  | "DTN_AG"
  | "MARKETS"
  | "GRAIN"
  | "CORN"
  | "SOYBEANS"
  | "WHEAT"
  | "COTTON"
  | "RICE"
  | "PEANUTS"
  | "OATS_AND_BARLEY"
  | "CATTLE"
  | "SWINE"
  | "DAIRY"
  | "SHEEP"
  | "HAY_AND_FEED"
  | "CANADIAN_MARKETS"
  | "CANADIAN_GRAIN"
  | "CANADIAN_LIVESTOCK";

This type describes the available news categories.

Configuration

apiKey

apiKey: string;

The widget access api key associated with your DTN account.

container

container: HTMLElement | string;

The container to mount the widget on. This can be a reference to an HTML element, or a valid selector string. If a string is encountered, document.querySelector will be used to search document for the container.

categories

categories?: NewsCategories[];

The categories option allows customizing what news categories are to show articles from. There is no limit on the armount of categories.

maximumArticleCount

maximumArticleCount?: number;

The maximum number of articles to display. Depending on the categories configured there may be less articles. There will never be more.

displayArticle

displayArticle?: boolean = false;

Whether the news article to be shown upon page load. Default set to false.

Callbacks

onArticleSelect

onArticleSelect: (articleId: string) => void;

This callback will be called whenever an article in the list is selected. It is called with the selected article's ID.