To answer my own question here is the right solution (after doing some investigations on what Sitecore Climber wrote):
- Create new class that inherits the
Sitecore.Buckets.Forms.SelectRenderingDatasourceForm
from dll
Sitecore.Buckets
this is the namespace found on tag CodeBeside in
\Website\sitecore\shell\Applications\Dialogs\SelectRenderingDatasource\SelectRenderingDatasource.xml
probably depending on your sitecore version you can have different namespace there so inherit whatever you have there set.
- Override the OnLoad method with:
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
if (NeedToDisable)
DisableCreateOption();
}
Now since DisableCreateOption is private we need to copy it to our code to be able to call it.
private void DisableCreateOption(){
this.CreateOption.Disabled = true;
this.CreateOption.Class = "option-disabled";
this.CreateOption.Click ="javascript:void(0);";
this.CreateIcon.Src = Images.GetThemedImageSource(this.CreateIcon.Src,
ImageDimension.id32x32, true);
}
- Do some logic in the NeedToDisable property that will return if the 'Create new content' buttons needs or not to be disabled.
public bool NeedToDisable{
return true; //replace this with your logic
}
Build and make sure your new changes are in the dll in website bin.
Go to \Website\sitecore\shell\Applications\Dialogs\SelectRenderingDatasource\ directory and open SelectRenderingDatasource.xml
Change the CodeBeside tag from old type 'Sitecore.Buckets.Forms.SelectRenderingDatasourceForm, Sitecore.Buckets' to your new created class in the dll.
Enjoy the new functionality.
Everything works great and as expected, except point 3, now I want to make the NeedToDisable property dynamic depending on an extra checkbox field I set on the rendering template and I will check or not.
My problem now is if there is a way to get a reference to the rendering fields when I am on this dialog.
I think that maybe I need to override the previous dialog where you select the rendering type the new component will be but not sure where can I find this.

Any ideas?