Skip to content

Feature Request: -PassThru for Add-Rendering #1163

Description

@bic742

Expected Behavior

Add-Rendering returns the RenderingDefinition object associated with the newly added rendering. This is helpful for cases where dynamic placeholders are in use, and the unique id of the Instance is leveraged to determine a generated placeholder value.

Actual Behavior

Add-Rendering does not currently return a value. This makes it difficult to dynamically build pages via SPE. The specific use case I am processing is building pages during content migration.

Current Work-around

If you leverage the -Index parameter for Add-Rendering and Get-Rendering, then you can get to the correct instance to grab the unique id:

Add-Rendering -Item $item -PlaceHolder $placeholderPath -Instance $accordionSectionRendering -DataSource $datasource.ID -FinalLayout -Index $renderingIndex
$accordionSectionInstance = Get-Rendering -Item $item -Placeholder $placeholderPath -FinalLayout -Index $renderingIndex
$renderingIndex++

Proposed Feature

Add support for -PassThru switch on the Add-Rendering method. Switch will allow user to capture the RenderingDefinition instance of the newly added rendering in a variable and use it to calculate any dynamic placeholder that was generated by that rendering:

$rendering = Add-Rendering -Item $item -PlaceHolder $placeholderPath -Instance accordionSectionRendering -DataSource $datasource.ID -FinalLayout -PassThru

Please include the version number of SPE and Sitecore.

  • Sitecore 9.2
  • SPE 6.0
  • Tested issue with clean install of Sitecore and the latest available version of SPE.

  • Asked questions on the Sitecore Slack Chat channel.

  • Reviewed questions and answers on the Sitecore Stack Exchange.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions