This project is read-only.

How to return multiple shapes from Driver .Display()?

Topics: Customizing Orchard, General, Writing modules
Apr 20, 2012 at 7:41 PM

I have a part that emits two shapes, each going to different local zones. Right now, as a workaround to accomplish this I created two Driver classes for this ContentPart. The 2nd driver class only implements .Display(), and I use to push the shapes into the correct zones. Works perfectly and i'm fine going into production with things as they are. 

Out of curiosity I want to know how to accomplish the same thing by returning multiple shapes from the same .Display() method. I think I saw this discussed somewhere but I can't remember it and can't find anything with a search. 

Apr 20, 2012 at 7:45 PM

Return a composite shape. There are plenty of examples of that throughout the code.

Apr 20, 2012 at 8:13 PM

How do I search for composite shape examples? I'm not sure what search term to use, since I don't know what I'm looking for. 

Is a composite shape different than creating a shape with properties? Because I've already tried passing the 2nd shape as a property of the 1st one, like this:

                return ContentShape("Shape1", () => shapeHelper.Shape1(Shape2: shape2)); 

I didn't expect this to work, but tried it anyways. Ss expected, it didn't work. I don't know the technical reason why; I guess because it doesn't make it into the shape table or something like that?

Apr 20, 2012 at 8:26 PM

You should use the "Combined" method instead of "ContentShape". It will return an appropriate CombinedResult object, and Orchard will take care of the rest.

Apr 20, 2012 at 9:10 PM

Perfect, thanks!