Skip to content

Instantly share code, notes, and snippets.

@fluxdigital
Last active August 14, 2019 21:09
Show Gist options
  • Save fluxdigital/8ecb9f1ac6a23f8e43fcc7bc1217b86f to your computer and use it in GitHub Desktop.
Save fluxdigital/8ecb9f1ac6a23f8e43fcc7bc1217b86f to your computer and use it in GitHub Desktop.
creates a view rendering at the specified location and adds datasource, data template and cache settings.
function Scaffold-View-Rendering([string]$renderingName, [string]$renderingPath, [string]$viewPath, [string]$dataSourcePath, [string]$dataSourceTemplate){
###create rendering###
$renderingItem = New-Item -Path $renderingPath -Name $renderingName -ItemType "/sitecore/templates/System/Layout/Renderings/View rendering"
$renderingItem.Editing.BeginEdit();
#set path
$renderingItem["Path"] = $viewPath;
#set default rendering icon
$renderingItem["__Icon"] = "/~/icon/office/32x32/element.png";
#add datasource and datasource location
$renderingItem["Datasource Location"] = $dataSourcePath;
$renderingItem["Datasource Template"] = $dataSourceTemplate;
$renderingItem["Cacheable"] = 1;
$renderingItem["VaryByData"] = 1;
$renderingItem.Editing.EndEdit();
Write-Host "Rendering Created & Configured: $($renderingItem.Name)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment