This project is read-only.

Alternates in Admin via Module

Topics: Customizing Orchard, Writing modules
May 2, 2011 at 4:00 PM

I'm trying to understand how alternates work within the admin context.  Specifically I'm trying to override the container EditorTemplate for my custom content type.  If I create MyModule\Views\EditorTemplates\Parts\Container.cshtml, it correctly overrides the default EditorTemplate, however it overrides across the board.  I've tried everything I can think of given the syntax provided in the docs, however I think it should be MyModule\Views\EditorTemplates\Parts\Container-MyContentType.cshtml, but I can't get it to work.  I also tried using the file along with the "Alternate=" syntax, but no dice.

Is it possible to override an EditorTemplate for a specific content type within a module?

May 2, 2011 at 9:04 PM

The admin is not yet using the shape infrastructure as much as it should. That is one of the things we'll be working on for 2.0. Overriding a template from a module, from another module, isn't something that can be reliably done currently as far as I know. Can you explain what you are trying to achieve?

May 2, 2011 at 9:23 PM

Well I'm currently using container/containable relationships with my custom types.  I'm hoping to work with randompete to collaborate with him on his more flexible relationships module, however that is what I'm currently using.  Basically, for the items that I'm creating, all of the extra fields in the editor for container (i.e. contains, order by, page size) are really not pertinent.  I was hoping to hide them for my specific type and use hidden fields.

I know I can create my own 1-n/n-n relationships, however I'm really trying to leverage existing systems.

May 2, 2011 at 9:36 PM

I don't think alternates will work from modules. Your simplest option is probably to create your own part (which could still leverage the container info from common).

May 2, 2011 at 9:54 PM

Yep, I started down that road and found myself pretty much completely duplicating the List admin piece (i.e. listing contained items, moving items between containers, etc).  Thanks though.