Skip to content

Commit

Permalink
Updated examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellwest committed Aug 4, 2019
1 parent 8bc2ba5 commit 90de2ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Expand Up @@ -21,13 +21,21 @@ SharedFields:
$sourceTemplate = Get-Item 'master:\templates\Sample\Sample Item'
$targetTemplate = Get-Item 'master:\templates\Sample\Sample Item'
$result = Read-Variable -Parameters `
@{ Name = "root"; Title="Branch to work on"; Root="/sitecore/"; Tooltip="Items you want to work on."}, `
@{ Name = "sourceTemplate"; Title="Current template"; Root="/sitecore/templates/"; Tooltip="Template you want to replace."}, `
@{ Name = "targetTemplate"; Title="New template"; Root="/sitecore/templates/"; Tooltip="Template you want to use."} `
-Description "This report will replace template on all items in the tree with another template of your choice" `
-Title "Branch Template Replace" -Width 500 -Height 400 `
-OkButtonName "Replace" -CancelButtonName "Cancel"
$dialogProps = @{
Title = "Bulk Template Changer"
Description = "This will change all items matching the source template with the new target template."
OkButtonName = "Replace"
CancelButtonName = "Cancel"
Icon = "OfficeWhite/32x32/arrow_circle2.png"
ShowHints = $true
Parameters = @(
@{ Name = "root"; Title="Branch to work on"; Root="/sitecore/"; Tooltip="Items you want to work on."},
@{ Name = "sourceTemplate"; Title="Current template"; Root="/sitecore/templates/"; Tooltip="Template you want to replace."},
@{ Name = "targetTemplate"; Title="New template"; Root="/sitecore/templates/"; Tooltip="Template you want to use."}
)
}
$result = Read-Variable @dialogProps
if($result -ne "ok") {
Exit
Expand All @@ -37,9 +45,8 @@ SharedFields:
$targetTemplateItem = New-Object -TypeName "Sitecore.Data.Items.TemplateItem" -ArgumentList $targetTemplate
$items = Get-ChildItem $path -Recurse |
Where-Object { $_.TemplateID -eq $sourceTemplate.ID }
$items | ForEach-Object { $_.ChangeTemplate($targetTemplateItem) }
$items = Get-ChildItem $path -Recurse | Where-Object { $_.TemplateID -eq $sourceTemplate.ID }
$items | Set-ItemTemplate -TemplateItem $targetTemplateItem
if($items.Count -eq 0) {
Show-Alert "There are no items matching the specified criteria."
Expand Down
Expand Up @@ -9,6 +9,13 @@ SharedFields:
Hint: Script
Value: |
Write-Log "Single Task"
1..100 | ForEach-Object {
[Sitecore.Context]::Job.Status.Processed = $_
[Sitecore.Context]::Job.Status.Messages.Add("Processed item $($_)") > $null
}
- ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
Hint: __Sortorder
Value: 0
Languages:
- Language: da
Fields:
Expand Down

0 comments on commit 90de2ec

Please sign in to comment.