Last active
January 11, 2016 16:20
-
-
Save michaellwest/005d9782713cb8b2902c to your computer and use it in GitHub Desktop.
Total number of Sublayouts in your Sitecore instance along with referrer pages and caching parameters
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
<# | |
Total number of Sublayouts in your Sitecore instance along with referrer pages and caching parameters | |
#> | |
$selectedItem = Get-Item -Path "master:\layout" | |
$result = Read-Variable -Parameters ` | |
@{ Name = "selectedItem"; Title = "Please select the path to query"; Root="/sitecore/layout/"} -Width 500 -Height 280 -OkButtonName "Proceed" -CancelButtonName "Abort" | |
if($result -ne "ok") { | |
Close-Window | |
Exit | |
} | |
$sublayoutPath = $selectedItem.Paths.Path | |
$querySublayouts = "fast:$($layoutPath)//*[@@templatename='Sublayout' or @@templatename='Controller rendering' or @@templatename='Item rendering' or @@templatename='Method rendering' or @@templatename='Rendering' or @@templatename='Url rendering' or @@templatename='View rendering' or @@templatename='Webcontrol' or @@templatename='Xsl rendering']"; | |
$sublayouts = Get-Item -Path "master:\" -Query $querySublayouts | |
function Get-RenderingPageCount { | |
param( | |
[string]$Id | |
) | |
$query = "fast://*[@__Renderings='%$($Id)%']" | |
$count = Get-Item -Path "master:\" -Query $query | Measure-Object | Select-Object -ExpandProperty Count | |
if(!$count) { | |
$count = 0 | |
} | |
$count | |
} | |
function Get-CachingValue { | |
param( | |
[Sitecore.Data.Items.Item]$Item | |
) | |
$values = @() | |
if($Item.Cacheable) { | |
$values += "Cacheable" | |
} | |
if($Item.ClearOnIndexUpdate) { | |
$values += "ClearOnIndexUpdate" | |
} | |
if($Item.VaryByData) { | |
$values += "VaryByData" | |
} | |
if($Item.VaryByDevice) { | |
$values += "VaryByDevice" | |
} | |
if($Item.VaryByLogin) { | |
$values += "VaryByLogin" | |
} | |
if($Item.VaryByParm) { | |
$values += "VaryByParm" | |
} | |
if($Item.VaryByQueryString) { | |
$values += "VaryByQueryString" | |
} | |
if($Item.VaryByUser) { | |
$values += "VaryByUser" | |
} | |
$values -join "<br/>" | |
} | |
foreach($sublayout in $sublayouts) { | |
Add-Member -InputObject $sublayout -MemberType NoteProperty -Name "File Path" -Value $sublayout.Path | |
Add-Member -InputObject $sublayout -MemberType NoteProperty -Name "Pages Created" -Value (Get-RenderingPageCount -Id $sublayout.ID) | |
Add-Member -InputObject $sublayout -MemberType NoteProperty -Name "Caching" -Value (Get-CachingValue -Item $sublayout) | |
} | |
$sublayouts | Show-ListView -Property Name, Path, "File Path", "Pages Created", "Caching" | |
#$sublayouts | Show-ListView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment