November 16, 2015

Customize the ExperienceEditor Part 3 - Accessing to the registry from the javascript

Here is my other post of the same series about the customization of the client without modifying the Sitecore JS:
If you need to save boolean into the registry like the collapsed state of an element to keep the content editor's preferences you can do:

Retreive the current state:

Sitecore.ExperienceEditor.PipelinesUtil.generateRequestProcessor("ExperienceEditor.ToggleRegistryKey.Get",
    function (response) {
       mystate = response.responseValue.value;
    },{ value: "/Current_User/Page Editor/MyModule/MyValue" }).execute();
Where
  • function(response) is the function executed when you will receive the response.
  • response.responseValue.value is a boolean with the returned value. The default value of this registry is true (stored as "on" in the registry)
  • MyRegistryKey.IsCollapsed is the a unique key in the registry for the user.

Toggle the value when the user collapse the control for example

Sitecore.ExperienceEditor.PipelinesUtil.generateRequestProcessor("ExperienceEditor.ToggleRegistryKey.Toggle",
    function (response) {
        top.sidebar.isCollapsed = response.responseValue.value;
    }, { value: "/Current_User/Page Editor/MyModule/MyValue" }).execute();
You can use the same method to call the different requests commands from the Sitecore config node sitecore.experienceeditor.speak.requests who are stored by default in Sitecore.ExperienceEditor.Speak.Requests.config

1 comment: