BuildEditor partial?

Topics: Customizing Orchard
Jan 12, 2013 at 10:51 AM
Edited Jan 12, 2013 at 10:54 AM

You see I can very well use this kind of snippet:

<..> BuildEditor(contentItem) <...>

but in result I see in the Editor Form all the shapes for all the parts of the item.

In my case I'd like to limit editing only to some of the parts.
Sort of if I could remove the unneeded parts from Model..?

I wouldn't like to use because this limitation concerns only
a specific Admin Theme while on the main Admin the Editor must be full.

Now I can see the only workaround that is using CSS.

Do anybody know how to "filter" BuildEditor ?

Jan 12, 2013 at 7:31 PM

Found ....

   public static class ShapeHelper {
        private static readonly Func<object> _nullFunc = () => null;

        public static void Remove(dynamic model, string[] Prefix) {
            var zones = new Dictionary<string, object>();

            ((IClayBehaviorProvider)model).Behavior.GetMembers(_nullFunc, model, zones);

            var key = zones.Keys.FirstOrDefault(a => a == "Content");

            dynamic zone = zones[key] as IShape;
            ((List<object>)zone.Items).RemoveAll(a => Prefix.Contains(((IShape)a).Metadata.Prefix));