Add Sitecore Content Editor ribbon button to show page components
Posted 25 Mar 2025 by Marek Musielak
One of our clients asked us if we could add an additional Sitecore Content Editor button near the Presentation Details link that would allow users to see all the components, their placeholders, and datasources on one screen, and moreover, that would provide Sitecore Content Editor deep links to both rendering and datasource items. I followed the steps below in order to create a ribbon button with Sitecore Powershell Extensions.
I wrote this blog post while working for Blastic, a company that delivers great Sitecore solutions and much more.
You don't even need to start Visual Studio. Log in to the Sitecore backend and open Sitecore Content Editor. Then follow the steps:
-
Add a new
PowerShell Script Module Folderitem under/sitecore/system/Modules/PowerShell/Script Library/SPEcalledCustomizations. -
Add a new
PowerShell Script Moduleitem under the folder item created earlier, call itRibbonand check theEnabledcheckbox. -
Then use the
PowerShell Script Librarytemplate to create 4 items under theRibbonitem:/sitecore/system/Modules/PowerShell/Script Library/SPE/Customizations/Ribbon/Content Editor/Ribbon/Presentation/Layout. -
And finally, use the
PowerShelltemplate to create theRenderingsitem. -
On
Renderingsitems, set theEnable Rulefield towhere the item has a layoutand paste the script below into theScript bodyfield. Your structure should look like this:
$device = Get-LayoutDevice -Default $renderings = Get-Rendering -Item $SitecoreContextItem -Device $device -FinalLayout $data = @() foreach ($rendering in $renderings) { if ($rendering.ItemID -ne $null) { $renderingItem = $null $datasourcePath = $null $datasourceId = $null $renderingPath = $null $renderingId = $null $renderingItem = Get-Item master: -ID $rendering.ItemID -ErrorAction Ignore if ($renderingItem -ne $null) { $datasource = $null if (![String]::IsNullOrEmpty($rendering.Datasource)) { $guid = [System.Guid]::empty if ([System.Guid]::TryParse($rendering.Datasource,[System.Management.Automation.PSReference]$guid)) { $datasource = Get-Item -Path ("master:\" + $rendering.Datasource) } else { $datasource = $SitecoreContextItem.Axes.SelectSingleItem($rendering.Datasource) } $datasourcePath = $datasource.Paths.FullPath $datasourceId = $datasource.ID.ToString() } $renderingId = $renderingItem.ID.ToString() $renderingPath = $renderingItem.Paths.FullPath } $data += @{ Rendering = "<a href='/sitecore/shell/Applications/Content%20Editor.aspx?fo=$renderingId'>$renderingPath</a>" Placeholder = $rendering.Placeholder DatasourcePath = "<a href='/sitecore/shell/Applications/Content%20Editor.aspx?fo=$datasourceId'>$datasourcePath</a>" } } } $data | Show-ListView -Property ` @{Label="Rendering"; Expression={$_.Rendering} }, @{Label="Placeholder"; Expression={$_.Placeholder} }, @{Label="Datasource"; Expression={$_.DatasourcePath} } Close-Window
Go back to the Sitecore Launchpad and start the PowerShell ISE application. Switch to the SETTINGS tab, click on the down arrow near Rebuild All... and choose Sync Library with Content Editor Ribbon option:
Switch back to the Sitecore Content Editor and select any item with a layout. On the PRESENTATION ribbon, you should now see a new button called Renderings. Click on it and you will see a list like this one:
Both Rendering and Datasource columns contain links which you can open in a new browser tab to deep link directly to that item in the Sitecore Content Editor.
To summarize, the custom ribbon button I’ve added enhances the Sitecore Content Editor by giving users quick access to all components, placeholders, and datasources, with deep links to relevant items. This solution, implemented with Sitecore PowerShell Extensions, makes the content management process easier.