This project is read-only.

Alternate shape on admin edit view

Topics: Administration, Customizing Orchard
Feb 18, 2013 at 5:18 PM
I am trying to specify an alternate editor for the Containable part in the admin panel. I have a custom admin theme that is working well and I'm able to override the Containable part for all content types by placing a Containable.cshtml in the EditorTemplates folder. I want to specify an alternate only when editing a particular content type.

I created an IShapeTableProvider as follows:
    public class AdminShapeProvider : IShapeTableProvider
        public void Discover(ShapeTableBuilder builder)
                    ContentItem item = displaying.Shape.ContentItem;
                    if (item.ContentType == "MyType")
The discover method is called a number of times, but the delegate never appears to be called. Any idea what I'm missing?
Feb 19, 2013 at 3:17 AM
The admin is not yet implementing the full set of nice things we have on the front-end. This looks to be one of them. Please file a bug if there isn't one already.

I would, however, not vary an editor template based on something like the content type. It feels icky: the theme doesn't seem like the right place to vary behavior (and if it's not behavior that you're changing, I'm not sure what you're trying to do here), and the content type being just an aggregation of parts, it should not affect the parts. I think it's ok and hard to avoid in some scenarios to have some dependency between parts, but having a part depend on what type it's in, for me, crosses a line.

So I would rethink this and try to make the variation depend on something else. If that something else is only turned on on that one type, fine, but it seems a lot cleaner to me.

Then again I know nothing of your scenario.
Feb 19, 2013 at 3:46 PM
Thanks Bertrand,

I'll give your comments some thought. What I'm trying to do is really trivial, I want to change the labels on the containable part to be more specific. Our app has a staff profile content type. Staff members are grouped by division. In this context the container of a profile is the Division and the Weight is the display order. I want to change the labels on the containable part to represent those concepts so the admin experience is a little more friendly. I can make it work though.

Thanks for all your help and everything you do for the community. Orchard just keeps getting better!
Feb 21, 2013 at 2:31 AM
Maybe container/containable is not the right choice for you. Did you consider the content picker field? It allows for a lot more flexibility and customizations.
Mar 20, 2013 at 4:19 AM
Agree that the theme doesnt really feel like the right place to vary the behaviour here, but I have a similiar requirement in which I want the default selection for the "Add To" field for the Containable part to be a specific list; and isn't changing the editor template is going to be much easier than replicating the entire Containable part (since theres no extension point for adding your own settings / behaviour to this?)

(and as for why I want the default selection to be something instead of none, its so that content editors dont accidentlly create items that dont go into a default List that has been created for them, for a specific content type)