Created
December 17, 2018 23:15
-
-
Save fluxdigital/63b7dee44e54b7eec30e8790a54dc77b to your computer and use it in GitHub Desktop.
Swaps one rendering for another and optionally swaps out the datasource too
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Swap-Rendering ($item, $renderingToSwapOut, $placeholder, $renderingIdToAdd, $renderingDataSourceIdToAdd, $useFinalLayout) { | |
$renderingItem = Get-Item -Path $renderingToSwapOut.ItemID | |
Write-Host "Swaping Rendering: $($renderingToSwapOut.UniqueID) - '$($renderingItem.Name)' in Placeholder: $($placeholder) to: $($renderingIdToAdd) - '$($renderingToAdd.Name)' for Item: $($item.Name)" | |
$renderingToSwapOut.ItemID = $renderingIdToAdd | |
if($renderingDataSourceToAdd){ | |
$renderingToSwapOut.Datasource = $renderingDataSourceToAdd | |
} | |
Set-Rendering -Item $item -Instance $renderingToSwapOut -FinalLayout:$useFinalLayout | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment