How to enable Custom Display Types.

Topics: Writing modules
Sep 23, 2013 at 3:06 AM
Edited Sep 23, 2013 at 3:20 AM
I trying to use a custom display type for a content item but cannot seem to get it to use the expected view (.cshtml). Eventually I want to be able to overload this custom view within themes.

Here are the details:
  • Use a Projection Layout that renders a display type other than Detail and Summary, these are used in other places of the site.
  • I have the custom display type in Placement.info
  • I have the view parts\Test.MiniSummary.cshtml but seems to be using the parts\Test.Summary.cshtml (I can see this in Shape Tracing)
  • Correct display type is being passed to the driver.
Here is the basic return from the driver
        return this.Combined(
            this.ContentShape(
            "Parts_Test",
            () => shapeHelper.Parts_Test(Test: viewModel)),
            this.ContentShape(
            "Parts_Test_MiniSummary",
            () => shapeHelper.Parts_Test_MiniSummary(Test: viewModel)),
            this.ContentShape(
            "Parts_Test_SummaryAdmin",
            () => shapeHelper.Parts_Test_SummaryAdmin(Test: viewModel)),
             this.ContentShape(
            "Parts_Test_Summary",
            () => shapeHelper.Parts_Test_Summary(Test: viewModel)));
Any clue on this issue if greatly appreciated.
Coordinator
Sep 23, 2013 at 3:09 AM
You did not say what your display type is named.
Sep 23, 2013 at 3:13 AM
The DisplayType is MiniSummary.
Sep 23, 2013 at 3:49 AM
The other interesting thing. If I force it to use a particular ContentShape the results are very odd.
            if (displayType.Equals("MiniSummary"))
            {
                return this.ContentShape(
                    "Parts_Test_MiniSummary",
                    () => shapeHelper.Parts_Test_MiniSummary(Test: viewModel));
            }
When I do this nothing is rendered and in Shape Tracing I get a shape of Content, which is not at all expected. In all cases in the Tracing tool I see Display Type MiniSummary so that seems to be set correctly.
Coordinator
Sep 23, 2013 at 4:06 AM
The Content shape is normal and expected, and the Combined shape really is what you want to do. Please show your placement file.
Sep 23, 2013 at 4:24 AM
Edited Sep 23, 2013 at 4:24 AM
Thanks so much your question sparked the answer the issue was indeed Placement.info. All I needed was to add the MiniSummary version of the result.

Here was the fix:
    <Match DisplayType="MiniSummary">
      <Place Parts_Test_MiniSummary="Content:1"/>
    </Match>
Coordinator
Sep 23, 2013 at 4:37 AM
Cool :) Custom display types are an underused and wonderful feature. Have fun!
Sep 23, 2013 at 5:59 AM
Thanks so much this solves a somewhat big issue with a site I am responsible for, very good way to end a weekend :).