Nested shapes & zones from a driver

Topics: Customizing Orchard, General, Writing modules
Jul 27, 2011 at 9:59 PM

Hey all, I'm trying to figure out how to do nested shapes (and put them into a zone) from a driver.  I'm at a loss.  Say from my driver I have a parent shape, with two child shapes of the same type, and I want to return one ContentShapeResult that contains the hierarchy of shapes.  In the template for the parent shape, I then have a zone for the child shapes, which then get displayed individually.  I feel crazy, but I can't find an example of nested shapes that go to zones anywhere, even though I know that's how the entire orchard system is built (it's just abstracted enough so that each driver returns a single shape, and it gets nested/zoned in a way that I can't figure out).  

Jul 27, 2011 at 10:06 PM

I think @Display is the key here.

Jul 27, 2011 at 10:17 PM

Right, I understand that, but I can't figure out how to declare a nested shape in a driver such that the child shapes can be controlled via the file.  I can do this:

var shape1 = shapeHelper.Child_Shape();
var shape2 = shapeHelper.Child_Shape();

return ContentShape("Parent_Shape", () =>

     Children = new List<dynamic> { shape1, shape2 }

And in my view I can do this:

    @foreach (var child in Model.Children)
But only the parent shape is affected by the zones/


Jul 27, 2011 at 10:49 PM

How are you expecting placement to affect this? Child_Shape doesn't have anything under it that could be placed, and I don't see your template for Child_Shape where you are defining the local zones that would be the target for placement.

Sep 6, 2011 at 8:55 AM

I'm also interested in this answer.

Assume for a minute that the child shape's .cshtml contained:

How would I render to this Zone (Model.ChildContent) - Using doesn't seem to work. And what would I call the zone? Is it still a local zone?
Been trying for more than a day to get this right and failing.

Sep 8, 2011 at 10:46 PM

You might want to try calling that child shape Content and maybe nest it one level deeper, something like Model.Child.Content.