Alternate view for field editor

Topics: Customizing Orchard
Jun 5, 2011 at 9:01 PM

Hi, I would like to override text field editor. I created my view and I modified placement.info file (Order of field was changed). Unfortunatelly I don't know where should I paste my custom template.

Jun 5, 2011 at 10:13 PM

Into your custom Theme, in the same folder it was under in the original module. See tutorials in orchardproject.net documentation for creating a theme.

Jun 6, 2011 at 4:49 PM

Ok, I wan't to replace Common Text Field. I have created the following entry in placement.info:

<Place Fields_Common_Text_Edit-Color="Content;Alternate=Fields_Common_Text_Edit__Color" />  
And I created file Fields.Common.Text.Edit-Color.cshtml and place it in:
Core/Common/Views/EditorTemplates
Themes/TheAdmin/Views/EditorTemplates
Themes/MyTheme/Views/EditorTemplates
but still I don't see it.
Coordinator
Jun 6, 2011 at 5:31 PM

That's because the admin theme has a higher priority than your theme. Overriding admin templates is not a supported scenario at this point. It's doable by implementing a theme selector and giving your theme a higher priority though.

Jun 6, 2011 at 6:01 PM

I don't understand.

I can change location of field by modify placement.info in TheAdmin theme.
I can change theme of generic text field editor by placing file Fields.Common.Text.Edit.cshtml in ~/Themes/TheAdmin/Views/EditorTemplates

I can't only specify alternative template for specific filed name.

Coordinator
Jun 6, 2011 at 6:24 PM

You are not supposed to modify what's in TheAdmin: what's going to happen next time you update the application? Well, your changes are going to get overwritten. That's why you should work in your own theme. I'm not exactly sure why what you're trying to do isn't working but as I said, not supported. If I had to guess I would say that the name of the alternate may not be right.

Coordinator
Jun 6, 2011 at 6:26 PM

Can you explain what exactly you're trying to do, so that maybe we can find a different solution for the same scenario?

Jun 6, 2011 at 7:04 PM

I have my custom type with few text fields.

I'd like to create custom editor for one of this fields.

Coordinator
Jun 6, 2011 at 7:09 PM

That much I had understood :) My question was more why do you want to do that? What will this achieve? We might find another way.

Developer
Jun 1, 2012 at 1:51 PM
Edited Jun 1, 2012 at 1:53 PM

Simply overriding specific field editors seems not to be possible now neither. I wanted to override the Text field's editor shape from a module, but for only that specific content type's field. Fields.Common.Text.Edit.cshtml override works, but it overrides all editors. Despite the Fields.Common.Text-ContentType-FieldName.cshtml pattern working for display shapes, Fields.Common.Text.Edit-ContentType-FieldName.cshtml doesn't.

Anybody with a clue? Only the overriding from Placement.info remains, but it's less comfortable (the model object such a template gets is not the same statically types one the original editor template gets).

Coordinator
Jun 1, 2012 at 6:27 PM

Overriding admin templates is tricky. I think you found the best way for the current build.

Developer
Jun 1, 2012 at 7:45 PM

Thanks!