0
votes

I have seen the following post which looks similar to mine. Issue displaying the summary view of a custom content part in Orchard CMS using Placement.info

But when I compared my code with the solution I could not find anything different.

This is what I want to achieve:

I have two custom Content Parts built QuestionRecord and ExpertRecord. The relation between these two parts are Experts answer to Questions posted by site users.

I have a global search module which is supposed to display a combined summary result of Questions and Expert Answers. But Expert part is somehow not picking up the Summary view, it is always showing the detail view.

Placement.info:

 <Match ContentType="ExpertRecord">
     <Match DisplayType="Detail">
       ... ...
     </Match>
     <Match DisplayType="Summary">
       <Place Parts_Expert_Summary="Content:2" />
       <Place Parts_Expert="-" />
     </Match>
 </Match>

Driver Result methods in ExpertDriver:

 protected override DriverResult Display(Expert part, string displayType, dynamic shapeHelper)
 {
        List<dynamic> questions = new List<dynamic>();
        string partName = "Parts_Expert";
        switch (displayType)
        {
            case "Detail":
                // only load questions when showing detail record.
                questions = _questionService.GetQuestionsByExpert(part.ContentItem);
                break;
            case "Summary":
                partName += "_Summary";
                break;
        }
        return ContentShape(partName,
            () => shapeHelper.Parts_Expert(ContentItem: part.ContentItem, Questions: questions));
 }

Views:

@Model dynamic
<p>This is my Expert_Summary.cshtml file</p>

I want this View to be called on from the DriverResult method, but it is calling the detail view Experts.cshtml. Both views are placed in Parts folder.

I must be missing something but could not figure out what exactly it is.

I am still fairly new to Orchard so any suggestion would be a great help for me.

Regards

1

1 Answers

1
votes

Have your driver return a Combined shape with both the regular and the summary shape, and let placement sort it out. There are lots of examples throughout the code, that should be easy to find if you search for ".Combined".