add-rendering-to-placeholder
Add a rendering to a placeholder while validating it against the placeholder's allow-list, assigning a collision-free dynamic placeholder ID and returning the child placeholder path.
Instructions
Adds a rendering to a placeholder on a page, refusing it when the placeholder's settings do not allow that component (the allow-list is named in the error). This is the tool to compose a page with: presentation-add-rendering writes whatever it is told, and an invalid layout still saves and renders. Assigns a collision-free DynamicPlaceholderId when the rendering's parameters template defines one, and writes the full parameter set the template declares. Returns the placeholder path a child rendering should target, so a nested build is one call per level. Pass force=true to skip validation for migration or repair work. Read the guide://compose-page resource for the order to run the composition tools in, and for the dynamic placeholder, splitter and GridParameters cases that silently produce a broken page when guessed at.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | The full path of the item, database prefix optional (e.g. master:/sitecore/content/Stride/Cova/Home or /sitecore/content/Stride/Cova/Home). Supply this or pageId. | |
| force | No | Skip the placeholder-settings check and add the rendering anyway. For migration and repair work that legitimately has to write a layout the current settings forbid. The rendering item must still exist. | |
| index | No | Position to insert at within the placeholder. Appends by default. | |
| pageId | No | The ID of the page item (e.g. {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}). Supply this or path. | |
| project | No | Overrides the folder searched under /sitecore/layout/Placeholder Settings/Project. Defaults to the project (tenant) folder of the site the item belongs to, and falls back to the whole global Placeholder Settings tree. | |
| database | No | The database to read. Defaults to master, and is ignored when path carries its own prefix. | |
| language | No | The item language. Defaults to the context language. | |
| dataSource | No | The rendering's datasource. Use the local:/Data/<name> form for a page-local datasource, or an item ID for a shared one — create-component-datasource returns the correct form in DatasourceReference. | |
| parameters | No | Values for the rendering's parameters, keyed by parameter name (e.g. {'GridParameters': '{F38CFEF8-...}'}). Every key the parameters template defines is written whether or not it appears here; these are the ones that get a value. Names not defined by the template are rejected rather than written. | |
| finalLayout | No | Which layout to write. Defaults to true (the final layout), which is where authored pages carry their renderings. Set false to write the shared layout. | |
| placeholder | Yes | The placeholder to add the rendering to. The placeholder to resolve. Accepts a bare key ('headless-main', 'container', 'container-{*}') or a full runtime placeholder path ('/headless-main/page-section-1/container-2'), in which case the leaf segment is matched — including against the wildcard keys dynamic placeholders use. Use the exact runtime path for a nested placeholder — that is what gets written to the layout. | |
| renderingId | No | ID of the rendering definition item (e.g. {AD10DB7C-C944-42D9-9563-1F1070CC922E}). Supply this or renderingPath. | |
| renderingPath | No | Path of the rendering definition item (e.g. /sitecore/layout/Renderings/Project/Stride/RichText). Supply this or renderingId. | |
| dynamicPlaceholderId | No | Force a specific DynamicPlaceholderId instead of the scanned max+1. Only use this to reproduce an exact layout; a colliding ID silently merges two placeholders. |