November Happy Hour will be moved to Thursday December 5th.

EPiServer 7.13.1 - restricting content types in ContentArea

Vote:
 

Hi,

I'm using EPiServer 7.13.1. I want to restrict the content types in ContentArea. I tried with both AllowedTypes attribute and custom EditorDescriptor but nothing works. The editor is still allowed to create all block types inside that ContentArea.

http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2013/12/Restriction-of-content-types-in-properties/
http://world.episerver.com/Blogs/Ben-McKernan/Dates/2013/11/Restricting-the-allowed-types-in-a-content-area/

Any help would be greatly appreciated!

#90120
Sep 02, 2014 12:59
Vote:
 

AllowedTypes will stop the editor from drag n' drop content and also from the All Properties view. However, it will not stop editors from using the quick link in the property to create a new block, which is bad.

AllowedTypes doesn't work with interfaces or base classes. But you can override this behaviour. Given you have an interface called ITag and you want to limit the content area to just content that implements this interface:

[UIDescriptorRegistration]
public class TagUIDescriptor : UIDescriptor
{
}

[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class InitializationModule1 : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        var uiDescriptorRegistry = ServiceLocator.Current.GetInstance();
        var descriptors = uiDescriptorRegistry.GetAllRegisteredUIDescriptors();

        var types = new[]
        { 
            typeof(ITag) 
        };

        foreach (var descriptor in descriptors)
        {
            foreach (var type in types)
            {
                if (type.IsAssignableFrom(descriptor.ForType))
                {
                    descriptor.DndTypes.Add(type.FullName.ToLowerInvariant());
                }
            }

        }
    }

    public void Preload(string[] parameters) { }

    public void Uninitialize(InitializationEngine context) { }
}
#90143
Edited, Sep 02, 2014 22:24
Vote:
 

Oh btw, this topic is discussed here http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=86968

#90145
Sep 02, 2014 22:58
Vote:
 

Hi Johan,

I'm not using interfaces / base classes in AllowedTypes attribute.

edit:

The editor cannot 'drag & drop' disallowed block types, but he can still click on 'create a new block' link and get a list of all block types. Can I filter that list somehow? I know that I can create a custom Validator and prevent the editor to save the page, but I'd like to filter that list as well.

Thanks!

#90159
Edited, Sep 03, 2014 10:53
Vote:
 

http://world.episerver.com/Support/Bug-list-beta/bug/110190/

#90164
Sep 03, 2014 11:21
Vote:
 

"However, it will not stop editors from using the quick link in the property to create a new block, which is bad."

Great that it is reported as a bug now.

#90171
Sep 03, 2014 12:20
Vote:
 

It's been reported as a bug for quite some time, and it also has by far, the most votes on the bug list so I really hope that it means that the development team get's this fixed soon. FYI: There is actually need for some new functionality to solve this "glitch" and that's the main reason why it has not been fixed yet.

#90179
Sep 03, 2014 12:42
Vote:
 

+1

#90502
Sep 10, 2014 23:13
Vote:
 

Hey, Linus, do you have any info about when this bugfix will be released?

#113301
Nov 18, 2014 11:58
Vote:
 

Hi,
We are planing to start to work on this feature very soon. Right now we are working hard to get the IE 11 support out (TinyMCE upgrading right now) and it has taken longer than expected.

But I can't give you an exact date when it is going to be released. But it has very high priority.

/Magnus

#113307
Nov 18, 2014 13:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.