Disable constructive role programmatically

I was wondering if there is a way to toggle / disable the designer role from the code. The desired effect of the command: webedit:toggledesigncapability

.

Image of the command in the page editor:

SkPL7tb.png

How can I switch design capabilities from code?

+3


source to share


1 answer


The code below toggles the state of this parameter for the current user. It should work for you, or at least point you in the right direction. I didn't have time to test it, so you have to do it yourself. Don't forget to refresh the page after running the code:



string key = "/Current_User/Page Editor/Capability/design";
if (Sitecore.Web.UI.HtmlControls.Registry.GetString(key, "on") == "on")
{
    Sitecore.Web.UI.HtmlControls.Registry.SetString(key, "off");
}
else
{
    if (WebEditUtil.CanDesignItem(Sitecore.Context.Item))
    {
        Sitecore.Web.UI.HtmlControls.Registry.SetString(key, "on");
    }
}

      

+2


source







All Articles