Delete confirmation when deleting from the floating menu in the page editor in the sitecore file

I am a very new sitecore, working with sitecore 7. The question is when I am in the page editor, when I delete an item using the "delete" function of the floating menu, it just removes the item.

The customer’s requirement is to add a confirmation field here. Something like "you must delete." and two typical buttons (yes / cancel).

what is even possible? Any help would be appreciated.

EDIT: In the image below, Red Cross, delete / delete button. If I click, it will simply delete. I want to show confirmation when I click a button.

enter image description here

EDIT 2:

Ok, I am writing a user command. I added a new button. The goal is that this new button will ask if the user wants to remove the component or not. And if the user says yes, he will do the same as the default built-in delete button.

enter image description here

the code:

public class RemoveWithNoti:Sitecore.Shell.Applications.WebEdit.Commands.WebEditCommand
    {
        public override void Execute(CommandContext context)
        {

            Context.ClientPage.Start(this, "Run", context.Parameters);
        }

    protected static void Run(ClientPipelineArgs args)
    {
        if (args.IsPostBack)
        {
            if (args.HasResult)
            {
                //Here I need to call "chrome:rendering:delete" this . I just dont know how to!!

            }
        }
        else
        {
            SheerResponse.Confirm("Are you certain that you want to remove this component");
            args.WaitForPostBack();
        }
    }
    }

How do I call chrome: render: remove from code ??

+4
source share
1 answer

The chrome: rendering: delete event is handled on the client side by javascript. Here are the exact locations: / sitecore / shell / Applications / Page Modes /ChromeTypes/RenderingChromeType.js file:

handleMessage: function(message, params, sender) {
    switch (message) {
...
      case "chrome:rendering:delete": 
        this.deleteControl();
        break;
...
},

You can do something like this in the same file:

deleteControl: function() {
    if(confirm('Are you sure to remove this component?')){
        var placeholder = this.getPlaceholder();

        if (placeholder) {     
          placeholder.type.deleteControl(this.chrome);      
        }
    }
}
+3
source

Source: https://habr.com/ru/post/1649390/


All Articles