Use Sitecore Powershell Console to Find Templates with Layout

Wed Sep 12 2012

Undoubtedly someone will tell me an easier way to do this after I post, but was just saved by the Sitecore Powershell Console module yet again. Used it to find references to my base layout underneath /sitecore/templates -- i.e. templates that have a layout assigned on their standard values. Pretty snazzy.

PS master:\layout\Layouts> $layout = get-item BaseLayout
PS master:\layout\Layouts> $linkDatabase = [Sitecore.Globals]::LinkDatabase
PS master:\layout\Layouts> $links = $linkDatabase.GetReferrers($layout)
PS master:\layout\Layouts> $links | foreach-object { if ($_.GetSourceItem() -and $_.GetSourceItem().Paths.Path.ToLower().StartsWith("/sitecore/templates")) { write-host $_.GetSourceItem().Paths.Path } }
/sitecore/templates/snip/Event/Event/__Standard Values  
/sitecore/templates/snip/Generic/Generic Article/__Standard Values  
/sitecore/templates/Branches/snip/Site Root/$name/Home/Products/Categories  
/sitecore/templates/snip/Generic/Generic Detail/__Standard Values  
/sitecore/templates/snip/Education/Category/__Standard Values   
/sitecore/templates/snip/Home/__Standard Values  
/sitecore/templates/snip/Error/__Standard Values  
(etc)

Looks like I have some branch templates to look at too.

Loading...
Nick Wesselman

Nick Wesselman started working professionally in software development just a few days after everyone realized we dodged a bullet with the Y2k bug. He’s worked as a Sitecore solution partner, Technology partner, and now for Sitecore itself. He lives with his wife, son, and daughter in Asheville, NC.