Datasources
12 min
overview a data source is the configuration that tells a list component (e g , a list, swiper, or dropdown) where to fetch its data from and how to present it data sources are defined inside component configurations in views json and handle fetching, caching, pagination, and making data available to child components through the context system every data source shares a set of common configuration properties and has a type field that determines which data it loads data source types type description content issues, bundles, and posts from the catalog api publication publications from the catalog api subscription subscription plans that are available for purchase search result full text search results taxonomy taxonomy nodes (tags, topics, etc ) collection content contents of a specific collection collection collections from the catalog api (deprecated, use collection content ) json arbitrary json array from a url or local resource file custom statically defined list of items in views json context data already present in $context , re exposed as a list bookmark user's bookmarked content menu menu items from the catalog api period time periods (years/months) derived from issue publication dates acm reco ai powered content recommendations via acm ad ad slots from the ad configuration issue issues (deprecated, use content ) category categories (deprecated, use taxonomy ) common configuration these properties are available on every data source type property type default description type string — required identifies which data source to use (see table above) contextkey string — key under which loaded data is published in $context , e g $context mykey gives the array of items contextproperty string — when set, only this property of each item is stored in context instead of the full object (e g id to store only ids) limit number — maximum total number of items to load offset number — skip the first n items batchsize number 24 number of items fetched per api call (used for lazy loading / "load more") cursor string — starting cursor, overrides the default start position randomize boolean false randomize the order of loaded items maxcacheage number global default cache ttl override in milliseconds preventssrcache boolean false forces the client to re fetch data even when ssr cached data is available (use for user specific data like entitlements) ad object — insert ads between items — see ad insertion /#ad insertion loadall boolean false (deprecated) keeps loading until no next page exists all numeric properties ( limit , offset , batchsize , maxcacheage ) also accept a string (parsed as an integer) or a conditional value conditional values any property that accepts a conditional value can be written in one of three forms // plain value "limit" 10 // conditional — use 10 if condition is true, otherwise no limit "limit" { "value" 10, "condition" { "value" "$context someflag", "operation" "set" } } // conditional with fallback — use 10 if true, 5 otherwise "limit" { "value" 10, "condition" { "value" "$context someflag", "operation" "set" }, "fallback" 5 } when the condition is not met and no fallback is provided, the property behaves as if it was not set conditions a condition object controls whether a filter clause or conditional value is active at runtime conditions are evaluated against the current context condition properties property type description value string the value to evaluate (supports $context , $global , $functions — see value interpolation ) operation string comparison operation (see table below) default equals comparevalue string the reference value to compare against negated boolean invert the result of the condition stringignorecase boolean use case insensitive string comparison and condition\[] all conditions must be true or condition\[] at least one condition must be true operations operation description equals value == comparevalue (default) equals not value != comparevalue set value is not null/empty not set value is null or empty empty value is an empty array or string not empty value is a non empty array or string contains value (string or array) contains comparevalue less than parseint(value) < parseint(comparevalue) greater than parseint(value) > parseint(comparevalue) example { "condition" { "and" \[ { "value" "$context publication id", "operation" "set" }, { "value" "$context platform", "operation" "equals not", "comparevalue" "web" } ] } } value interpolation string values inside filters and conditions are dynamically resolved at runtime three scopes are available identifier access pattern description $context $context publication id current view context — publication, issue, category, search result, platform, etc $global $global experienceconfig mykey globally loaded data available across all views (see global data https //app archbee com/docs/qtjkvew7g556yo3qfoyay/hh7yttoxelethdlpm 7dl ) $functions $functions myfn(arg1, arg2) custom javascript functions registered in custom js dot notation and bracket notation are both supported $context issue title , $context\['search result'] excerpt when a $context or $global path resolves to null or undefined , any url segment containing that value is automatically removed from the resulting string filter path param interpolation filter values that start with are automatically replaced with the matching url path parameter for example, a filter value of \ publicationid resolves to the publicationid segment of the current url at runtime this allows a single view definition to serve filtered content for any publication without additional custom logic filter logic (and / or) all filter types support and and or arrays for combining multiple filter clauses each clause can carry its own condition so individual clauses can be toggled at runtime "filter" { "or" \[ { "id" { "value" "pub 123" } }, { "id" { "value" "pub 456" }, "condition" { "value" "$context platform", "operation" "equals", "comparevalue" "web" } } ] } a filter clause whose condition evaluates to false is silently dropped if all clauses are dropped, the filter is treated as absent when a filter value is an array , it is automatically expanded into an or across all values, so "value" \["a", "b"] is equivalent to or \[{ value "a" }, { value "b" }] ad insertion a data source can interleave ad slots into its item list using the ad property "ad" { "adid" "banner ad", "interval" 3, "after" 1, "indexed" true, "startindex" 0 } property description adid id of the ad definition from ads json interval one ad is inserted for every n regular items after first ad appears after this many items (defaults to interval ) indexed append a numeric suffix to adid for each ad slot (e g banner ad0 , banner ad1 ) startindex starting index for the suffix when indexed is true (default 0 ) the ad property also accepts a condition value to enable or disable ad insertion at runtime