This post intends to get you familiar with where Sitecore keeps code for dialogs that are rendered in Experience Editor and how they can be modified using a problem we solved recently.
PROBLEM
We may want to hide some out-of-box elements in Sitecore's Experience Editor for meeting specific business needs. In our case, we were upgrading from Sitecore 8.2 to Sitecore 10.1.1 recently and migrated our vanilla Sitecore sites to be SXA site. We decided to keep content author experience in Sitecore 10 instance as close as possible to Sitecore 8 so that we don't end up re-training our content authors spread globally almost in every country. Obviously, SXA presents a slightly different interface in Experience Editor and we started finding workaround for them.
We observed that, in Experience Editor, while creating/selecting a rendering's datasource, there is a new Clone Current Content option which didn't exist in Sitecore 8 as in snapshot below -
We found that the Select the Associated Content dialog is rendered using SelectRenderingDatasource.xml present at below location -
C:\inetpub\wwwroot\<local sitecore instance name>\sitecore\shell\override\Applications\Dialogs\SelectRenderingDatasource
Following part in the SelectRenderingDatasource.xml is responsible for showing the Clone Current Content option -
<!--Clone-->
<Border ID="CloneOption">
<a href="#" class="mode">
<div>
<ThemedImage Class="mode-icon" Src="Office/32x32/clone_item.png" />
<div class="mode-text">
<Literal ID="CloneCurrent" Text="Clone Current Content" />
</div>
</div>
</a></Border>
We initially tried commenting the above section to disable the Clone Current Content option but that started giving us below error -
The error is because in the code beside, the cloning section is used in the OnLoad() method. As a workaround, we decided to hide the section using Visible="false" instead of removing it completely. So the xml for Clone Current Content option in SelectRenderingDatasource.xml looked like below -<!--Clone-->
<Border ID="CloneOption" Visible="false">
<a href="#" class="mode">
<div>
<ThemedImage Class="mode-icon" Src="Office/32x32/clone_item.png" />
<div class="mode-text">
<Literal ID="CloneCurrent" Text="Clone Current Content" />
</div>
</div>
</a>
</Border>
This perfectly did the job and Clone Current Content option was no more visible to the content authors.
You can use similar approach to hide any other elements in similar XMLs which render different controls/dialogs in Experience Editor.
I hope you find this useful. Thanks!!