4

I am currently working on a project using Sitecore version 8.2.7 and our client asked us if we can disable drag-and-drop function so that they do not have to worry about any accidental item deletion.

We first came up with an idea that denying their access rights (delete) but they said they might want to delete items from the Content Editor.

Now we are asked if we can disable moving items on the Content Editor's GUI.

Any ideas and thoughts are appricated.

2
  • Can you elaborate on the "drag-and-drop" functionality? Are you using SXA on your instance? Sep 27, 2018 at 16:37
  • No I am not using SXA on my instance. What I meant by "drag-and-drop functionality" is moving items by mouse on the Content Editor.
    – TestUser
    Sep 28, 2018 at 1:28

2 Answers 2

8

Yes it is possible to disable the drag option. From my investigation, there are 2 ways you can disable it.

Solution 1: Comment Out Javascript

You can disable the drag and drop feature by commenting out the method initialize in the javascript.

  • Navigate to the \Website\sitecore\shell\Applications\Content Manager\Content Editor.js.

  • Open the Js file and search for var scContentEditorDragDrop = Class.create({

  • Comment out the code. Please see below

enter image description here

Solution 2: Custom pipeline

You can implement a pipeline and add it to the <uiDragItemTo>. When dragging item starts, it will check if the item can be drag or not. Below is the sample code snippet

public class Draggable
{
    public void IsDraggable(ClientPipelineArgs args)
    {
        Assert.ArgumentNotNull((object)args, nameof(args));

        // Logic to check if dragging item is enable
        // if yes, show dialog and abort pipeline.

        Context.ClientPage.ClientResponse.Alert("You cannot drag an item. Feature is disabled.");
        args.AbortPipeline();

    }
}

When the item will be drag and drop, the below error message will appear and it will not drag the item.

enter image description here

You need to patch the config so that your patch is in first order.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <processors>
      <uiDragItemTo>
        <processor patch:before="processor[@type='Sitecore.Shell.Framework.Pipelines.DragItemTo,Sitecore.Kernel']"
            type="YourNamespace.Draggable,YourAssemblyName" method="IsDraggable"/>
      </uiDragItemTo>
    </processors>
  </sitecore>
</configuration>

My recommendation is to go for Solution 2.

0

From what I know, you cannot disable it using any setting. You need to edit the Sitecore javascript files.

Find the file

sitecore\shell\Applications\Content Manager\Content Editor.js

go to the onNodeDrop function and remove the content of it (or just add return; at the beginning of it).

Make sure you clear your browser cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.