Applying Views to Content Types

Topics: Customizing Orchard
Mar 26, 2011 at 5:07 PM

How exactly does one go about applying a view to the editor for a content type to override the default view?  I have built a content type called events following the docs, but now I want to modify the template for the form that is used to edit that content type.  I essentially want to change the output.  What naming convention do I use and what directory?  If there is documentation on this topic, just point me to it.  I've been looking and can't find anything specific to this.  Can I modify the annotations to accomplish things like repositioning?


Mar 26, 2011 at 6:41 PM
Edited Mar 26, 2011 at 6:41 PM

You have to override the editors for individual content parts. Which parts / fields have you built it with?

If you just want to rearrange stuff, you can move things around using a file.

Mar 26, 2011 at 11:34 PM

I've built my custom content type via the web interface and it has the following parts:

Body, Comments, Common, Tags Route

And I have added the following fields:

where (text), eventstart (datetimefield), eventend (datetimefield)

I basically want the editor view to have the fields in the following order:

- Title

- Location

- EventStart  (custom date time field) and EventEnd (custom date time field) - these should appear on the same line.

- Body

- Tags

Some questions about the file: 

- how do I determine the name to use in the Place element?

- how do I determine the name to use in the Match - DisplayType element?

- since Orchard is MVC based, I was hoping I could simply create a view to override the default view and then place that view in my themes' view directory.  Is this even an option?  I understand that the file might make it simpler to modify via the interface, but I don't mind using my own Views and rather prefer it.

Mar 27, 2011 at 12:30 AM
Edited Mar 27, 2011 at 12:32 AM

An Orchard page is composed up of many small view fragments. You don't want to go overriding large sections of the UI; an individual module could get updated but your view would still be displaying the old version. This could mean you lose functionality or even worse, things could break.

By using you can do a massive amount of customisation without having to change any templates (you can even push stuff to different zones in the layout).

See the following thread regarding placement names for fields:

I was just searching for documentation regarding for parts and other bits, I found this:,info

Note: It's draft documentation for 1.1 but I think you'll have to be using that anyway for positioning fields.

If you need further help, what I've seen has been kind of scattered around various module authoring tutorials, but I can try and dig up some more. You can also search this forum for and see what comes up!

The only other problem is:

- EventStart  (custom date time field) and EventEnd (custom date time field) - these should appear on the same line.

To handle this I guess you'd have to build a custom "DateRangeField", and supply your own field editor template which included both inputs. Have a read of the following tutorial from the Orchard documentation which details how the DateField is built:

Should be possible to extend that example for a two date range (with some creative thinking!)

Edit: Just one more note; if you want to override a specific part or field's views, you should be able to copy the corresponding file into the same path in your theme structure. So you can customise individual view fragments where needed - with the caveat that if you ever update to a new version of that module, you should check for anything new in their templates.

Mar 27, 2011 at 1:56 AM

I had found the links you specified but it still does not make sense and I can't get even a simple example to work with placement info:

I created in the root of my themes directory and I want to try and inject the WHERE field into the top of the content area.  I've tried a number of different combinations but none seem to work.  Basically, for my content type Event, I want the Where field to appear at the top of the form when in editing mode.


  <Match ContentType="Event">
   <Place Fields_Common_Text__Where="Content:1" />

I am sorry if these are newbie questions but I have been going over the docs and forums for a while and am still very confused and feel a bit stupid. I have worked with MVC for a couple of years and have done quite a lot of work with Sitecore and Umbraco and find Orchard every confusing. One of the things that attracted me to Orchard was that it was based on MVC and I figured it would have a low barrier to entry for someone familiar with MVC.

Maybe an FAQ for beginners going over basics might be a good document. For example, how in the world do I modify the label that is output in a form from the name the field is given? Something like that should be straightforward but I can't figure it out. Is there an admin section I can do this in (I can't find one)? Is it placed into the file (I don't think so from what I have read)? Do I annotate a model (I created the content type from the admin interface so I doubt it but I could be wrong)? Do I create a razor view within my theme providing a different label name? What about setting a field to be required? Where do I add validations for content types that I create via the web interface? Normally, I would use Data Annotations. However, that does not make sense given the creation of the shape on the fly. There is nothing in the Content Type admin area. So how is that done?

Mar 27, 2011 at 3:39 AM

There is a bug in 1.0.20 preventing named field placement from working.

Seeing the amount of control you are looking for, it makes little sense to use fields, and you should instead build your own content part.

Mar 27, 2011 at 10:16 PM

Ah, that would explain a lot.  Thanks for the pointer.  I started to go with the build my own and am much happier.