This project is read-only.

Finding zone of shape.

Topics: Customizing Orchard, Writing modules, Writing themes
Sep 10, 2012 at 11:47 AM
Edited Sep 10, 2012 at 11:48 AM

Hello all,

I have a simple problem, well at least I think it's simple, but I'm struggling to find a way to do it.

builder.Describe("Parts_Common_Body_Summary").OnDisplaying(displaying =>
	var bodyShape = displaying.Shape;

I want to find out what zone the 'bodyShape' shape is in. 

The scenario is adding an alternate based on the zone that the body is displaying in, so I can truncate the text to different lengths based on where it is on the page. If there is an easier way to achieve what I'm trying to do, I'd be glad to hear about it.

I'm constrained to Orchard 1.3, otherwise I think this might be easier.


Sep 12, 2012 at 6:15 PM

A shape doesn't know what it's in, but the widget alternate feature is adding alternates that may help here.

Sep 13, 2012 at 8:32 AM

Ok, thanks. Good to have confirmation. I've checked out the widget alternate feature and think I can make it work for what I need. Cheers.

Sep 13, 2012 at 3:29 PM
Edited Sep 13, 2012 at 3:31 PM

I couldn't get the widget alternate feature to work, so

For anyone else wanting to do this:

I eventually implemented what I wanted by overriding the ContainerWidgetPartDriver from Orchard.Core using the [OrchardSuppressDependency] attribute and passing through the zone on the container widget shape.

return ContentShape("Parts_ContainerWidget", () =>

    return shapeHelper.Parts_ContainerWidget(Zone: part.As<WidgetPart>().Zone, ContentItems: list);

I was then able to add a zone specific alternate to the Parts_ContainerWidget shape in an IShapeTableProvider.

This still seems like a bit of a meal so let me know if anyone finds a simpler/better way to do it.