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...

5
  • Have you tried the Security Editor to revoke 'Read' from the required item for that specific Role?
    – TamerM
    Commented Nov 7, 2016 at 10:52
  • If you are creating a 'sitecore' domain user, then why do you want to disable entire tree ? Commented Nov 7, 2016 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? Commented Nov 7, 2016 at 11:14
  • 1
    I've edited the question title, to better match what was being asked.
    – Mark Cassidy
    Commented Nov 7, 2016 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
    Commented Nov 7, 2016 at 11:46

1 Answer 1

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.

1
  • 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
    Commented Nov 8, 2016 at 10:20

Your Answer

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

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