This project is read-only.

Display Containable

Topics: Customizing Orchard, General
Mar 18, 2013 at 7:07 PM
I have created a custom view and with shape tracing I have been able to add all my fields to it except my containable. I have tried @Model.ContentItem.ContainerPart but that just returns Orchard.Core.Containers.Models.ContainerPart. Can someone please help?

Mar 18, 2013 at 9:42 PM
I'm not sure I understand what you're trying to do. Could you please explain what you mean by "it" ("I have been able to add all my fields to it")?
Mar 18, 2013 at 10:24 PM
I have a custom view (Content-Brand.Detail.cshtml). Brand is a container, and I am trying to add my containables (BrandReview) to my view.
Mar 19, 2013 at 12:32 AM
I see. Have a look at the ContainerPartDriver in Orchard.Core/Containers. You'll see that it creates the Parts_Container_Contained shape.
From your Content-Brand.Detail.cshtml view, render the Content zone at the exact position where you want to render the list of containables.
Then, create a view called Parts.Container.Contained. From within that part, you will have access to the List property, which is a list of rendered containables.
Mar 19, 2013 at 1:07 AM
My ContentType, Brand, already has tons of other fields which I am calling in my view like this Model.ContentItem.TitlePart.Title, Model.ContentItem.BodyPart.Text, etc. So far this method has worked very well for completely customizing the page. If I render the Content Zone, won't it render all of these fields too?
Mar 19, 2013 at 1:15 AM
Edited Mar 19, 2013 at 1:16 AM
Yes, but there's an easy way around that: make up your own local zone, e.g. call it "BrandReviews", and update your file to place the shape "Parts_Container_Contained" into the "BrandReviews" zone.
Mar 22, 2013 at 6:42 PM
Finally figured it out, thanks.