Placeholder setting

ok
04 Mar, 24
Sitecore

# Define the placeholder key and the rendering ID you are searching for

$placeholderKey = "your-placeholder-key"

$renderingIdToFind = "{RENDERING-ID-TO-FIND}"


# Retrieve the placeholder settings item for the given key

$placeholderSettingsItem = Get-ChildItem -Path "master:/sitecore/layout/Placeholder Settings" -Recurse | Where-Object { $_.PlaceholderKey -eq $placeholderKey }


if ($placeholderSettingsItem -ne $null) {

    # Retrieve the "Allowed Controls" field value, which is a list of rendering GUIDs

    $allowedControls = $placeholderSettingsItem["AllowedControls"] -split '|'


    # Check if the rendering ID is in the list of allowed controls

    if ($allowedControls -contains $renderingIdToFind) {

        Write-Host "The rendering with ID $renderingIdToFind is allowed in the placeholder $placeholderKey."

    } else {

        Write-Host "The rendering with ID $renderingIdToFind is not in the 'Allowed Controls' for the placeholder $placeholderKey."

    }

} else {

    Write-Host "No placeholder settings found for the key '$placeholderKey'."

}