Set-Layout
Sets item layout for a device.

Syntax

1
Set-Layout [-Item] <Item> -Device <DeviceItem> [-Layout <Item>] [-FinalLayout] [-Language <String[]>]
2
3
Set-Layout [-Path] <String> -Device <DeviceItem> [-Layout <Item>] [-FinalLayout] [-Language <String[]>]
4
5
Set-Layout -Id <String> [-Database <String>] -Device <DeviceItem> [-Layout <Item>] [-FinalLayout] [-Language <String[]>]
Copied!

Detailed Description

Sets item layout for a specific device provided
© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Device <DeviceItem>

Device for which to set layout.
Aliases
Text
Required?
true
Position?
named
Default Value
Accept Pipeline Input?
false
Accept Wildcard Characters?
false

-Layout <Item>

Sitecore item defining the layout.
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

-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

1
# where my test page will go
2
$path = 'master:\content\Sample'
3
4
# wipe and re-create it if exists
5
if(Test-Path $path){
6
Remove-Item $path
7
}
8
$item = New-Item -Path $path -ItemType "Sample/Sample Item"
9
10
# select default layout
11
$device = Get-LayoutDevice -Default
12
13
# and a layout we will change to
14
$layout = Get-Item -Path 'master:\layout\Layouts\System\Simulated Device Layout'
15
16
# change the layout from what is in Standard values to the new one.
17
Set-Layout -Item $item -Device $device -Layout $layout | Out-Null
18
19
# verify
20
Get-Layout $item
Copied!

Related Topics