The data is made available under the specified name and can then be used in textual content by means of placeholders.
Makes external data globally available to the application.
The data is made available under the specified name and can then be used in textual content by means of placeholders.
Params
name
(String) – The name under which the external data will be globally available.read
(Function) – An asynchronous callback for fetching the external data. Scrivito executes the passed-in function and waits for the returned promise to resolve with a plain JavaScript object representing the external data. If the promise resolves with null
, the corresponding external data is assumed to be missing.Returns
DataItem
(Object) – An object that can be used to provide an editing configuration for the external data.
Example
Make external data available under the name LoggedInUser
:
The external data can be referenced within textual content via placeholders:
When this text is rendered using Scrivito.ContentTag
, the placeholder is replaced with the referenced external data:
The external data is also available when content is being edited in place. Here’s how the object returned by Scrivito.provideDataItem
can be used to configure user-interface-related aspects:
See also Scrivito.provideEditingConfig
.
A placeholder consists of two underscores, followed by a valid identifier, a dot, then another valid identifier and another two underscores.
The first identifier references the name under which the external data was made available, e.g. LoggedInUser
or ProductDetails
, while the second identifier references the attribute name of the external data, e.g. email
or price
:
The key parts of a placeholder are its identifiers. They allow Scrivito to determine the value the placeholder stands for. Identifiers must follow these rules: