Skip to main content
Updated and highlighted the description
Source Link
Sumit Bhatia
  • 5.9k
  • 2
  • 9
  • 25

Try this code, I have modified the custom rendering parameter like the "Ajax Options"Ajax Options check box.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/xxx/xxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('Menu Wrapper')

$renderingParamterToUpdate = "Ajax Call"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}

$languages = @('en')

$startPath = '/sitecore/content/xxx/xxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('Menu Wrapper')

$renderingParamterToUpdate = "Ajax Call"

$newRenderingParameterValue = "0"




foreach($language in $languages){

    $items = Get-ChildItem -Path $startPath -Language $language -Recurse

    foreach($item in $items){

        Write-Host 'Updating Item: ' $item.Paths.FullPath

        foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

            $renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID    

            if($renderingNames -contains $renderingItem.Name){

                Write-Host 'Found Rendering: ' $($renderingItem.Name)                

                $parameters = Get-RenderingParameter -Rendering $itemRendering

                if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

                    Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

                    $parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

                    $itemRendering | Set-RenderingParameter -Parameter $parameters |

                    Set-Rendering -Item $item -FinalLayout

                }

            }

        }

    }

}

Try this code, I have modified the custom rendering parameter like the "Ajax Options" check box.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/xxx/xxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('Menu Wrapper')

$renderingParamterToUpdate = "Ajax Call"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}

Try this code, I have modified the custom rendering parameter like the Ajax Options check box.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/xxx/xxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('Menu Wrapper')

$renderingParamterToUpdate = "Ajax Call"

$newRenderingParameterValue = "0"




foreach($language in $languages){

    $items = Get-ChildItem -Path $startPath -Language $language -Recurse

    foreach($item in $items){

        Write-Host 'Updating Item: ' $item.Paths.FullPath

        foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

            $renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID    

            if($renderingNames -contains $renderingItem.Name){

                Write-Host 'Found Rendering: ' $($renderingItem.Name)                

                $parameters = Get-RenderingParameter -Rendering $itemRendering

                if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

                    Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

                    $parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

                    $itemRendering | Set-RenderingParameter -Parameter $parameters |

                    Set-Rendering -Item $item -FinalLayout

                }

            }

        }

    }

}
deleted 22 characters in body
Source Link

Try this code, I have modified the custom rendering parameter like the "Ajax Options" check box.

In this, the function takes as an input item you want to edit and field - either Final or Shared layout.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/OneWebxxx/McCormick USxxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('OneWeb Menu'Menu Wrapper')

$renderingParamterToUpdate = "Ajax Options"Call"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}

Try this code, I have modified the custom rendering parameter like the "Ajax Options" check box.

In this, the function takes as an input item you want to edit and field - either Final or Shared layout.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/OneWeb/McCormick US/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('OneWeb Menu Wrapper')

$renderingParamterToUpdate = "Ajax Options"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}

Try this code, I have modified the custom rendering parameter like the "Ajax Options" check box.

In this, the function takes as an input item you want to edit and field - either Final or Shared layout.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/xxx/xxx/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('Menu Wrapper')

$renderingParamterToUpdate = "Ajax Call"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}

Source Link

Try this code, I have modified the custom rendering parameter like the "Ajax Options" check box.

In this, the function takes as an input item you want to edit and field - either Final or Shared layout.

Also Write a log on every step:-

$languages = @('en')

$startPath = '/sitecore/content/OneWeb/McCormick US/Presentation/Partial Designs/Frenchs/Recipe'

$renderingNames = @('OneWeb Menu Wrapper')

$renderingParamterToUpdate = "Ajax Options"

$newRenderingParameterValue = "0"

foreach($language in $languages){

$items = Get-ChildItem -Path $startPath -Language $language -Recurse

foreach($item in $items){

Write-Host 'Updating Item: ' $item.Paths.FullPath

foreach($itemRendering in Get-Rendering -Item $item -FinalLayout) {

$renderingItem = Get-Item -Path master: -ID $itemRendering.ItemID

if($renderingNames -contains $renderingItem.Name){

Write-Host 'Found Rendering: ' $($renderingItem.Name)

$parameters = Get-RenderingParameter -Rendering $itemRendering

if($parameters[$renderingParamterToUpdate] -ne $newRenderingParameterValue){

Write-Host 'Updating' $renderingParamterToUpdate -ForegroundColor Green

$parameters[$renderingParamterToUpdate] = $newRenderingParameterValue

$itemRendering | Set-RenderingParameter -Parameter $parameters |

Set-Rendering -Item $item -FinalLayout

}

}

}

}

}