Variations
Variations override selected properties at a context key and inherit the remaining values.
For the team workflow, see Adapt a value.
Cells
Vox stores each variation as a cell: the values of some properties at a key of contexts, such as Market=se or
Channel=app|Market=se. A key names at most one context of each context type, and a cell only holds the properties it
changes:
[
{ "keys": ["Channel=app|Market=se"], "values": { "campaignHeadline": "Only in the Swedish app" } },
{ "keys": ["Market=se"], "values": { "campaignHeadline": "Only in Sweden" } }
]
A cell can have several keys when the same values apply in several contexts, eg ["Market=se", "Market=no"]. It's
one cell with one version, which applies at each of its keys.
Precedence
When an entity is read in some contexts, Vox applies the cells whose keys match them, from the least to the most
specific. A key matches when each of its contexts is selected, or is a fallback of a selected context. The more
specific key wins: one for Sweden in the app beats one for Sweden, and an exact context beats its fallback. Context
types are ranked by their stacking order, so of Market=se and Channel=app, the one whose type stacks higher wins.
The stacking order is set in code, with VoxOptions.ContextStackingOrder, from the highest to the lowest, and ranks
the application's context types only. Drafts and releases aren't ranked: they're
authoring scopes, whose version of an entity is composed before its
cells are resolved. Since the order decides which cells win, Vox stores it, and a deployment that changes it is
migrated: the calculated results of the cells are calculated again, and every durable publication is built in full.
An explicit null is a value. Leaving a property out of a cell means a less specific cell, or the entity itself,
decides it.
Relations
A variation can change relations too, in two ways depending on how the relation is declared:
-
An embedded relation, eg
List<VoxReference<Shelf>> Shelves, is a value like any other: a variation that sets it replaces the whole list in its contexts. A shelf added to the entity itself later doesn't reach that list. -
An index-backed relation,
IVoxRelationReferences<T>, is changed with links and unlinks, eg a product unlinked from a category only in Sweden:{"keys": ["Market=se"],"values": {},"links": { "categories": { "linked": [], "unlinked": [{ "entityType": "Category", "id": "outdoor" }] } }}The changes apply on top of the links of less specific contexts, so a category added to the product itself later is still in Sweden.
Relations read in a selection, both ways, resolve these changes: the categories of the product in Sweden leave out
outdoor, and the products of outdoor in Sweden leave out the product. Filters by relations in queries use the
entity's own links, like other filters.
What can vary
A variation changes presentation or contextual business values; it does not change how an entity is found. Filterable,
sortable, calculated, managed and unique properties cannot vary because filters, sorts, search indexes and uniqueness
rules must see one authoritative stored value. Neither can mirrored data or VoxVarying values, which vary on their
own contexts, nor an object that has imported fields in it, whose owned fields are set one by one instead.
Locally owned relations can vary, since filters by relations read the entity's own links. An index-backed relation's
ownership comes from the nearest ownership declaration on it or its containing objects, with the same defaults as
fields. A relation with a [VoxOwned] override inside an imported object can vary; a relation marked
[VoxImportOwned] directly cannot. Imported and system-owned relations cannot be changed through cell writes.
See Relation ownership.
The values of a variation are validated like a save of the entity: the entity, as it's read at each key of the cell with its values, must pass its validation attributes and validators, eg a Swedish name that's too long is rejected.
Calculated values can't be set in a variation, but they follow the variations they read. A product that caches the names of its categories shows the Swedish name of a category in a Swedish read, because Vox calculates the product again where something it read has variations. See Calculations.
This boundary makes variations predictable: first Vox selects an entity through its normal queries and permissions, then it applies the matching cells to the returned representation.
Use VoxVarying when a property intrinsically has a complete set of values by language, market or channel. Use a
variation when there is a useful value of the entity and only some context combinations need another one.
Editorial lifecycle
Each cell has its own version and optimistic-concurrency boundary, so editors of different markets don't conflict. Cells follow the content they're written to:
- Writing a cell to published content publishes it at once, and records a version in the history of the entity.
- Writing a cell to a draft or a content release changes the draft of the entity, and is published with it.
- Deleting a cell in a draft hides the published cell until the draft is published or reverted.
- A draft cell holds the values it changed, and reads its other values from the published cell at the same key. A draft that changes the Swedish title shows the published Swedish subtitle, also after it changes.
- A draft cell conflicts when the published cell changed after the draft began. The conflict is resolved per cell, by keeping the draft's values or using the published ones.
- Restoring an earlier version of an entity restores its cells as they were at that version.
A content release publishes the entity and its cells atomically with the rest of its items. This makes it possible to launch a market-specific campaign together with the products, prices and content it depends on.
The admin UI edits the cells on the Variations tab of an entity, from the same entity and context metadata used by the API, with a preview of the values in the contexts an editor picks. Another editor can build the same experience without knowledge of a particular Product or Campaign class.
See Languages, markets and channels, Drafts and publishing and Content releases.