8

I have a bunch of templates which have a Coveo Search Box View rendering associated on the standard values. I need to update the property "Reveal Advanced Query Suggestions" of all of them(a lot of templates in this case) and set them all to checked = false. Although I could manually update them all I'm looking for an automated way of doing such task. Anyone have done anything similar using sitecore powershell? I do have the powershell documentation and if I spend some time and play with it I'll figure that script on my own just wondering if anyone has ever done anything similar that they could share?

thanks

  • Is that property on the rendering parameters or on the item? – Richard Seal Sep 28 '16 at 18:06
  • The property is a rendering parameter – Diego Sep 28 '16 at 18:08
11

Quick test confirms that the following allows you to set a rendering parameter on existing items.

# Path to the Coveo rendering you need to update
$rendering = Get-Item "master:\sitecore\layout\Sublayouts\Sample Sublayout"

# Update this value for the path of all the templates whose std vals you wish to update
$items = Get-ChildItem -recurse master:\sitecore\templates\Sample

$items | % {
    $renderingInstance = Get-Rendering -Item $_ -Rendering $rendering
    if ($renderingInstance) {
        Set-Rendering -Item $_ -Instance $renderingInstance -Parameter @{
            # Put new/changed rendering parameter name and value here
            # Other existing values should be unchanged by this
            "Lorem" = "Ipsum"
        }
        Write-Host "Updated $($_.Paths.FullPath)"
    }
}

More information:

  • exactly what I was looking for. Thanks techphoria414 – Diego Sep 28 '16 at 20:08
  • As soon as I can get Gitbook to build this example will be added. – Michael West Oct 2 '16 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.