Nested Scheduled Content
Nested scheduled content lets a parent piece of scheduled content contain one or more child pieces in designated slots, composing more complex layouts (e.g. a hero with three promo tiles beneath it).
Overview
- A parent piece of scheduled content defines slots (placeholders) in its template using metadata of type
BannerId. - A child piece of scheduled content (nested) is assigned to each slot.
- Parent and child are stored separately; the relationship is tracked via
childIds(on the parent) andparentIds(on each child). - Only one level of nesting is allowed. Nested scheduled content cannot itself have nested scheduled content.
Scheduled Content Types
| Type | Description | Properties |
|---|---|---|
| Parent | Has one or more child items in its layout | childIds: string[] |
| Child (nested) | Renders inside a parent's slot | parentIds: string[] |
| Regular | Standalone; no children, no parents | No childIds or parentIds |
Defining Nested Slots in Code
In a parent's React/JSX template, a slot is declared with the BannerId type:
// Declare a slot: const <variableName> = $(<label>:BannerId)
const Col1 = $(col1:BannerId);
const Col2 = $(col2:BannerId);
const Col3 = $(col3:BannerId);
const ThreeColumnsAcross = () => (
<div className="container">
<Col1 />
<Col2 />
<Col3 />
</div>
);
export default ThreeColumnsAcross;
variableName(e.g.Col1) – Used as the component in JSX.label(e.g.col1) – Becomes the slot ID (lowercased, often kebab-case likecol1).BannerId– Marks this as a nested scheduled content slot.
Assigning Child Scheduled Content in the Visual Experience Engine
- Open a parent piece of scheduled content in the Visual Experience Engine.
- In the metadata section, each
BannerIdfield shows Select From Banner List. - Choose scheduled content to assign to that slot.
- Save. The Visual Experience Engine updates:
- Parent:
childIds= list of assigned child IDs - Each child:
parentIds= list of parent IDs (including this one)
- Parent:
Restrictions on which scheduled content can be selected:
- Cannot select the current (parent) item.
- Cannot select scheduled content that already has children (they are parents themselves).
- Cannot select deleted scheduled content.
- Scheduled content that itself has parents (is already nested) cannot have
BannerIdmetadata – "Nested Banners are not allowed to have Nested Banners."
Backend: Insert Inner Banner (Web Only)
For web scheduled content (appType === 'web'), when a parent is saved, the insertInnerBanner hook runs:
- Find BannerId variables – Parses the parent's raw code for
const X = $(label:BannerId). - Resolve IDs – Uses metadata
valueto map each slot to a child ID. - Inline child code – For each assigned child:
- Fetches the child's variant code
- Replaces template variables in the child
- Obfuscates and renames the child component
- Inlines it into the parent's
replacedcode
- Replace slot placeholders – Each
<Col1 />-style tag is replaced with a<div data-inner-filled="col1"><Inner_0_xyz /></div>that renders the inlined child. - Unassigned slots – Replaced with
<div data-inner-empty="col1"></div>. childIds– Set on the parent with the list of assigned child IDs.
This produces a single combined replaced code string used for SSR and pre-rendering.
Backend: Parent–Child Sync
When scheduled content is created or updated, parentChildBannerSync (runs in onResponse) keeps the relationship consistent:
- New children – If new IDs appear in
childIds, add the current item's ID to each child'sparentIds. - Removed children – If IDs are removed from
childIds, remove the current item's ID from those children'sparentIds. - Propagate to parents – If the current item has
parentIds(it is a child), each of its parents is re-processed:insertInnerBanner,fetchImageDims,transpile,preRender,fetchHTMLDims, then saved. This keeps parent compiled code in sync when a child changes.
Workflow Summary
- Create parent template – Use
BannerIdmetadata:const Col1 = $(col1:BannerId)and render<Col1 />in the layout. - Create child scheduled content – Standard scheduled content (images, simple React components, etc.).
- Assign children – In the parent's form, use "Select From Banner List" for each
BannerIdfield. - Save – The API runs
insertInnerBanner, updateschildIds/parentIds, and propagates changes to parents. - On the page – The web script loads scheduled content, initializes
NestedBannersContextfrom metadata, andNestedSlotRendererrenders each child in its slot.
Key Takeaways
- Parent scheduled content declares slots via
BannerIdmetadata and assigns child scheduled content in the Visual Experience Engine. - Child scheduled content is standalone scheduled content that renders inside parent slots; it cannot nest further.
- Backend (web): child code is inlined into the parent's
replacedcode for SSR;childIdsandparentIdstrack the relationship. - Frontend:
NestedSlotRendererandNestedBannersContexthandle runtime assignment and rendering; initialization comes from parent metadata when scheduled content loads.