Alternates for fields depending from displayType

Topics: General, Troubleshooting, Writing modules
Jul 8, 2012 at 1:37 PM

Hi community!

I'm working with content types that consist of fields (orchard and my own) only. And I would like to display it with help of magic of orchard .BuildDisplay() taking into account displayType of contentItem;

Everything works fine. But I want to be able to create different views for fields for different displayTypes.

For example,

I have content type with following fields: boolean, text, numeric, telephone, image.  And I want to display list of items in frontend with such displayTypes:  

  • default display type (display all fields with labels) (it works) 
  • bagde display type (display only text and numeric fields, without labels
  • table display type (display as usual table
  • gallery display type (only images without labels) 
  • calendar display type (another display type), etc

Is it possible to make this scenario work with no changes in orchard code (core and fields module)?


Regards, Evgeny

Jul 8, 2012 at 4:06 PM

You can create different layouts with a projection for each of your displays. Then use a specific Display type in the Layout which will let you use an alternate like MyContentType.MyDisplayType.cshtml.

You might need specific Layout types though, and I know there is a new module somewhere to render tables.