Data sources
A data source is a named list of published items that a page can show: the entries of a public collection, or data a module offers. Editors pick the source and change its settings (order, number of items, filters); they never write queries. The site fetches the items when it is built, so the pages stay fully static.
A page shows a source's items in two ways (the website editor, see Pages and posts):
- Repeat for each repeats what it holds once per item; formulas inside read the item's fields (
item.title). - The List and Cards starter components take one source each, added to the library once per source; a page that uses one picks how many items, and in what order.
What users can do
Editors, in the website editor:
- Add a Repeat for each and choose its source (Items from): one per public collection (for example Pages, Posts), plus module sources.
- Change the source's settings, which depend on the source:
- Order: newest or oldest first (or "Recently changed" for collections without drafts), then each sortable field A–Z or Z–A.
- Number of items: 1–100, default 12.
- Filters: one per public choice, yes/no, date and single relation field of the collection. Choices and yes/no offer Any (the default), dates offer Any, Upcoming or Past, a relation filter picks one entry (empty: all items).
- Show an item's fields with formulas in what the Repeat for each holds, and what shows when there are none.
- On an item template page (see Collections and entries), read the fields of the item the page
is built for anywhere on the page (
entry).
Visitors see the items as part of the static page, in the page's language.
Who may do it
| Action | Permission | Roles |
|---|---|---|
| Get a source's items (site build, preview) | content.read | admin, editor, ai |
| Show a source on a page | saving the page (collections.website-pages.update) | admin, editor, ai (drafts only) |
| Publish the page | collections.website-pages.publish | admin, editor |
There are no permissions specific to data sources. Module sources disappear while their module is switched off.
In the admin
In the website editor's Data tab, with a Repeat for each selected: Items from (the source), its settings
(Order, Number of items, the filters, labelled with the field's label, for a field in a group
Group: Field), Name of each item and What tells the items apart. Save problems (an unknown source, a
refused setting, a field the items don't have) are shown like other validation issues.
On the website
The site fetches each source's items when it builds a page, and also for the preview, the editor's canvas and the 404 page. Each item comes with its fields, its id and its page address, with its images and links ready to use. A source knows which page it is shown on, so a source such as the menu can mark the current page. A source that no longer exists (such as one of a module that was switched off) shows no items; any other problem stops the build.
Because the items are fixed when the site is built, they change on the site only after a rebuild (publishing triggers one). A date filter's Upcoming / Past is compared with the moment of the build; a date without a time with that day in the site's time zone.
Rules and limits
- Published only. Sources return published content and only the fields the collection shows on the site; singletons (navigation, footer) and collections that are not public have no source. Item template pages are left out of the Pages source.
- Settings are checked: an unknown order, more than 100 items or a filter value not on offer is refused; missing settings take their defaults.
- At most 100 items, whatever a source returns.
- Checked on save, so the build never meets a source it cannot use: the source must exist and its settings must pass; formulas are checked against the fields its items have.
- Languages. Items, option labels, dates and numbers come in the page's language. The source and settings are shared by all languages.
- Item pages. When a collection has item pages and a published template, each item carries its page address,
which formulas use for links (
item.path). Item pages themselves are built at publish. - The products source (shop): prices in euros, like the shop.
For developers
The code and its tests: shade/features/data/README.md in the shade repository.