Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generates a Templates.cs struct for a given Sitecore Template
function Get-CleanName()
{
param (
[string] $Name
)
return $Name.Replace(" ", "")
}
$templateItem = Get-Item .
$templateName = Get-CleanName -Name $templateItem.Name
Write-Host "public struct Templates"
Write-Host "{"
Write-Host " public struct $($templateName)"
Write-Host " {"
Write-Host " public const string Id = ""$($templateItem.ID)"";"
Write-Host ""
Write-Host " public struct Fields"
Write-Host " {"
foreach($section in $templateItem.Children)
{
foreach($field in $section.Children)
{
$fieldName = Get-CleanName -Name $field.Name
Write-Host " public const string $($fieldName) = ""$($field.ID)"";"
}
}
Write-Host " }"
Write-Host " }"
Write-Host "}"
@GuitarRich

This comment has been minimized.

Copy link
Owner Author

@GuitarRich GuitarRich commented Nov 15, 2018

Add this to an SPE Module in a Context Menu item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment