Can I place a shape from one content type in the local zone of another?

Topics: Customizing Orchard, Writing themes
Jul 13, 2011 at 7:48 PM

I feel like I saw a question like this recently, but I can't find it anywhere. If this is a duplicate, I apologize.

I have a couple different content types on a page - LessonPlan, and Download. I am using randompete's Paperclips feature to attach Downloads to LessonPlans, but I think that fact is insignificant. I have looked at several file attachment modules in the gallery, and none seem to be as close to what I want as Paperclips. 

When I emit my LessonPlan markup, I have a bunch of fields that I want to put in an unordered list - including the attached Downloads. For all other fields, I've managed to pull this off. I put something like this in my Content-LessonPlan.cshtml view...

	@if (Model.TabContent != null)

<ul class="tabs">

And then I use to assign some wrappers so that all of the other fields get wrapped in an <li></li> tag and placed inside of the TabContent zone.

However, I would also like to place the attached Download items in the TabContent zone of my LessonPlan, so that they can also be part of the unordered list. Can I do this? If The difficulty seems to lie in the fact that the placement rules for Downloads are applied in the context of a Download content type, not a LessonPlan content type. For those unfamiliar with Paperlips, I think what I am trying to do would be akin to trying to place a Widget in the local zone of a content type.

Jul 13, 2011 at 8:57 PM

Yes, you can do it (just not with placement), it's just a matter of finding the path to the zone you want, from the layout. A simpler example (using only top-level zones) can be found in my "buy from Amazon" module.

Jul 14, 2011 at 8:02 PM


I see the code you speak of in the Buy From Amazon module.

You mention that I need to find the path to the zone I want...what is the construct I use to build/traverse that path? I'm not familiar with how I get from "workContextAccessor.GetContext().Layout.Zones[name]" to traversing a path to a child zone. 

Jul 14, 2011 at 8:23 PM

I would recommend attaching a debugger and digging into the object model.

Jul 14, 2011 at 10:01 PM

I apologize for any frustrations caused by me being a complete dummy...but I cannot for the life of me figure out how to debug the object graph. I suspect the answer may lie in the "Dynamic View" property, but every time I expand that, I just get "Empty", with a message that no further information can be discovered about the object. Otherwise, I see several fields/properties, but none of them really mirror the items I see in the code.

For instance, if I set a breakpoint on the line of your BuyFromAmazonPartDriver that adds the shape to the correct zone, and set a watch on this...


...there is nowhere in any of the properties/fields that I can access in the debugger, that I see anything named "Zones" -- despite the fact that in your code, you are referencing


For that particular watch, I can expand fields named __interceptors, __target, and Metadata. But none of those, as far as I can tell, contain anything named Zones. I guess I just don't feel comfortable with my ability to debug the object model when I can't even find something that I can tell from your code I should be able to find. I am sure I am missing something obvious, but..what is it?

Jul 26, 2011 at 2:15 AM

Yes, the debugging experience is not optimal, although it improved a lot in 1.2. You need to dig a little deeper into those, under __interceptors/[0]/ClaySharp.Behavior and __target

Jul 26, 2011 at 7:53 PM

Yeah, I eventually found that __target was my best bet for viewing the object graph. I was expecting to see a Zones property, and not seeing it made me feel less confident about what I was actually viewing. Eventually I discovered that the zones were just in there as properties named according to the actual zone. 

Though in the end, randompete pointed out that I was misusing his Paperclips/Connectors features of Mechanics. I was overcomplicating things, as usual, it seems. His Paperclips feature intentionally adds parts to top-level zones...removing the Paperclips part from a Connector allowed me to add parts to child zones.

Jul 26, 2011 at 8:05 PM

Yeah, zones are just plain shapes.