Set-Rendering
Updates rendering with new values.

Syntax

1
Set-Rendering [-Item] <Item> -Instance <RenderingDefinition> [-Parameter <Hashtable>] [-PlaceHolder <String>] [-DataSource <String>] [-Index <Int32>] [-FinalLayout] [-Device <DeviceItem>] [-Language <String[]>]
2
​
3
Set-Rendering [-Path] <String> -Instance <RenderingDefinition> [-Parameter <Hashtable>] [-PlaceHolder <String>] [-DataSource <String>] [-Index <Int32>] [-FinalLayout] [-Device <DeviceItem>] [-Language <String[]>]
4
​
5
Set-Rendering -Id <String> [-Database <String>] -Instance <RenderingDefinition> [-Parameter <Hashtable>] [-PlaceHolder <String>] [-DataSource <String>] [-Index <Int32>] [-FinalLayout] [-Device <DeviceItem>] [-Language <String[]>]
Copied!

Detailed Description

Updates rendering instance with new values. The instance should be earlier obtained using Get-Rendering.
© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Instance <RenderingDefinition>

Instance of the Rendering to be updated.
Aliases
Text
Required?
true
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Parameter <Hashtable>

Rendering Parameters to be overriden on the Rendering that is being updated - if not specified the value provided in rendering definition specified in the Instance parameter will be used.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-PlaceHolder <String>

Placeholder path the Rendering should be added to - if not specified the value provided in rendering definition specified in the Instance parameter will be used.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-DataSource <String>

Data source of the Rendering - if not specified the value provided in rendering definition specified in the Instance parameter will be used.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Index <Int32>

If provided the rendering will be moved to the specified index.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-FinalLayout <SwitchParameter>

Targets the Final Layout. If not provided, the Shared Layout will be targeted. Applies to Sitecore 8.0 and higher only.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Device <DeviceItem>

Specifies the target device when applying the rendering changes.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Language <String[]>

Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Item <Item>

The item to be processed.
Aliases
Text
Required?
true
Position?
1
Default Value
​
Accept Pipeline Input?
true (ByValue, ByPropertyName)
Accept Wildcard Characters?
false

-Path <String>

Path to the item to be processed - can work with Language parameter to narrow the publication scope.
Aliases
Text
Required?
true
Position?
1
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Id <String>

Id of the item to be processed - can work with Language parameter to narrow the publication scope.
Aliases
Text
Required?
true
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.
Aliases
Text
Required?
false
Position?
named
Default Value
​
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.
  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Change all rendering's placeholder from main to footer.
1
$item = Get-Item -Path master:\content\home
2
Get-Rendering -Item $item -PlaceHolder "main" |
3
Foreach-Object {
4
$_.Placeholder = "footer";
5
Set-Rendering -Item $item -Instance $_
6
}
Copied!

EXAMPLE 2

Clear the datasource value for a rendering.
1
$item = Get-Item -Path master:\content\home
2
Get-Rendering -Item $item -PlaceHolder "main" |
3
Foreach-Object {
4
$_.DataSource = $null
5
Set-Rendering -Item $item -Instance $_
6
}
Copied!

Related Topics