Created
June 13, 2019 13:41
-
-
Save Wesley-Lomax/d4477592c7ce93771e55e1cd05f1094d to your computer and use it in GitHub Desktop.
Get count of Sitecore components on layout / page
This file contains 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
$item = gi "/sitecore/content/Habitat Sites/Habitat Home/home" -Language 'en' | |
$sharedLayoutField = $item.Fields[[Sitecore.FieldIDs]::LayoutField] | |
$finalLayoutField = $item.Fields[[Sitecore.FieldIDs]::FinalLayoutField] | |
$sharedLayoutXml = [Sitecore.Data.Fields.LayoutField]::GetFieldValue($sharedLayoutField) | |
$finalLayoutXml = [Sitecore.Data.Fields.LayoutField]::GetFieldValue($finalLayoutField) | |
$sharedLayout = [Sitecore.Layouts.LayoutDefinition]::Parse($sharedLayoutXml) | |
$finalLayout = [Sitecore.Layouts.LayoutDefinition]::Parse($finalLayoutXml) | |
$sharedLayout.Devices[0].Renderings.Count | |
$finalLayout.Devices[0].Renderings.Count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment