4

This page describes how to customize the content tree: https://doc.sitecore.net/sitecore_experience_platform/80/content_authoring/the_editing_tools/the_content_editor/customize_the_content_editor#_Customize_the_content_1

You can hide the Content tree, Entire tree, Hidden items, Standard fields, Raw values and Buckets.

How can I configure these for a specific role?

When a new user gets created with that specific role, by default I want him to have the 'Entire tree' disabled.

My guess is to override a Pipeline somewhere...

  • Have you tried the Security Editor to revoke 'Read' from the required item for that specific Role? – TamerM Nov 7 '16 at 10:52
  • If you are creating a 'sitecore' domain user, then why do you want to disable entire tree ? – Naveed Ahmad Nov 7 '16 at 11:03
  • I think your question is unclear. Can you please rephrase it to sound different from the one that has bee provided as potential duplicate? I think you are asking about how to configure which role has certain checkboxes enabled, am I right? – Szymon Kuzniak Nov 7 '16 at 11:14
  • 1
    I've edited the question title, to better match what was being asked. – Mark Cassidy Nov 7 '16 at 11:16
  • @NaveedAhmad I'm opening the Content Editor from an admin page where they don't have to see the full tree. And those users shouldn't be able to open the Content Editor in a different way. – Koen Heye Nov 7 '16 at 11:46
4

Write an event handler or pipeline processor and place inside following code:

if (Context.User.IsInRole("sitecore\\ROLE_NAME"))
{
    Sitecore.Shell.UserOptions.View.ShowEntireTree = false;
}

This will basically disable the EntireTree for your current user if he belongs to role ROLE_NAME

I would suggest to add this into some event, however this is your choice when and how often you need to revalidate it.

I would avoid anything that influence normal user experience, which is for instance: httpRequestBegin. So concentrate on pipelines/events that are used by logged users.

You can find some examples and POC below:

EVENT HANLDER

Configuration:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <events>
            <event name="security:loggedIn">
                <handler type="Sitecore.Playground.EventHandlers.DisableEntireTree, Sitecore.Playground" method="DisableEntireTreeMethod" />
            </event>
        </events>
    </sitecore>
</configuration>

Code:

namespace Sitecore.Playground.EventHandlers
{
    public class DisableEntireTree
    {
        public void DisableEntireTreeMethod(object sender, EventArgs args)
        {
            if (Context.User.IsInRole("sitecore\\Experience Explorer"))
            {
                UserOptions.View.ShowEntireTree = false;
            }
        }
    }
}

I tested it with item:saved event, everything worked fine but this not what you probably want.

PIPELINE PROCESSOR:

Configuration:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <pipelines>
            <renderContentEditor>
                <processor type="Sitecore.Playground.Pipelines.RenderContentEditor.DisableEntireTree, Sitecore.Playground" />
            </renderContentEditor>
        </pipelines>
    </sitecore>
</configuration>

Code:

namespace Sitecore.Playground.Pipelines.RenderContentEditor
{
    public class DisableEntireTree
    {
        public void Process(RenderContentEditorArgs args)
        {
            if (Context.User.IsInRole("sitecore\\Experience Explorer"))
            {
                UserOptions.View.ShowEntireTree = false;
            }
        }
    }
}

Works almost fine. During first load value in ribbon is changed but tree needs reload. Find your best match.

  • I've tested it out and it works! Instead of an event, I've added it in the loggedin processor. Apparently there are bugs in SC 8.1 that don't trigger the security:loggedIn/Out event: vlukashevych.wordpress.com/2016/02/11/… – Koen Heye Nov 8 '16 at 10:20
  • Cool. Thank you for extra information. – Alan Płócieniak Nov 8 '16 at 10:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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