Created
June 22, 2021 16:31
-
-
Save patelcp/480e13ea2d63c10159512fe6fefa8291 to your computer and use it in GitHub Desktop.
Sitecore PowerShell Module - Reporting
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
$TemplateID = "{guid}" | |
# Create a list of field names on the Standard Template. This will help us filter out extraneous fields. | |
$standardTemplate = Get-Item -Path "master:" -ID ([Sitecore.TemplateIDs]::StandardTemplate.ToString()) | |
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate | |
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique | |
# Change the Id to something other than the Sample Item template. | |
$itemTemplate = Get-Item -Path "master:" -ID $TemplateID | |
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate | |
$itemTemplateFields = $itemTemplateTemplateItem.OwnFields + $itemTemplateTemplateItem.Fields | Select-Object key, ID, Title, Type, Source, SortOrder, "Tooltip", "Description", @{Name="Path"; Expression={$_.InnerItem.Name }}, @{Name="Section"; Expression={$_.Section.Name }}, @{Name="SectionOrder"; Expression={$_.Section.SortOrder }}, @{Name="Template"; Expression={$_.InnerItem.Parent.Parent.Paths.Path -replace "/sitecore/templates/Project/MSK/MSKCC/mskccorg/"}} -Unique | |
$filterFields = $itemTemplateFields | Where-Object {$standardFields -notcontains $_.key } | Sort-Object Section, SectionOrder, SortOrder, key | |
# Set the Show-ListView Properties | |
$props = @{ | |
Title = $itemTemplateTemplateItem.Name + " Template Fields" | |
InfoTitle = "$($itemTemplateTemplateItem.Name)" | |
InfoDescription = "Id: $itemTemplateTemplateItem.Id) <br/> Base Templates: "+ ($itemTemplateTemplateItem.BaseTemplates.Name -join "; ") + "<br /> $($filterFields.Count) Fields" | |
Icon = $itemTemplateTemplateItem.Icon | |
PageSize = 50 | |
} | |
# Show the list of fields | |
$filterFields | Show-ListView @props -Property Template, Section, key, Title, Type, Source, ID, SortOrder, "Tooltip", "Description" | |
Close-Window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment