Content.cshtml and Display Type

Topics: Customizing Orchard, General
Dec 14, 2013 at 10:41 PM
Edited Dec 17, 2013 at 9:30 AM
I have a Projection Page, listing Biography records. Inside the AsideSecond I am showing list of upcoming Events (Grid 1 column)

1- Projection Page -> Content has a Display Type of Detail
2- Each Item inside Projection Page has a Display Type of Summary
3- Widget is using a Grid which has a Display Type of Detail
3- Each Item inside Upcoming Events Widget has a Display Type of Summary

If I override Content.cshtml, only the Projection Page Content is getting affected (Display Type Detail), the remaining are not (being Display Type with Summary).

I read somewhere that Content.cshtml replaces any other template if not overridden.

Can someone please illustrate more on this topic, regarding Content Templates and Display Types?

Dec 16, 2013 at 10:49 PM
Content, like any shape, can have alternates. Look for Content_summary.cshtml for example.
Dec 17, 2013 at 9:32 AM
If Content.cshtml is present in the custom theme, wouldn't that override Content_Detail.cshtml and Content_Summary.cshtml?
Dec 17, 2013 at 2:21 PM
Edited Dec 18, 2013 at 5:13 AM
Hi Bertrand,
I found it.

When Orchard Host starts, it loads all defined Shapes [Defined in all loaded modules + Core module] together with their Shape Templates [Defined in all modules, Core module, and Theme(s)].

Now rendering a Shape depends on two things:
  • Shape Template
  • Alternates
Orchard Host starts checking the Shape Template Alternates [From bottom of list to top], when it finds a Template it uses that to render the Shape. The more specific the location of the Shape Template the more probably it will be used by Orchard. Specificity levels starts from:
  • Current Theme
  • Base Theme (if any)
  • Remaining modules
In my example above, Orchard starts looking for a convenient Shape Template and found one inside Core module for Content.Summary.cshtml. If I remove or rename this template, it will use the Content.cshtml defined in the current theme.

Does the above make sense to you?

Dec 19, 2013 at 5:36 AM
Marked as answer by bhaidar on 12/19/2013 at 5:10 AM
Dec 19, 2013 at 12:10 PM
BertrandLeRoy wrote:
Thanks Bertrand!