How to control in which top level zones content items get rendered?

Topics: Customizing Orchard, General, Writing themes
Sep 10, 2012 at 7:53 PM
Edited Sep 10, 2012 at 8:48 PM

I was just following the 'Writing a Content Part' tutorial, and I was wondering if its possible to have more control over where content items are rendered on a page. I'm aware that the can be used to control on which local zones parts of the content type render, so is there something to control where in the top level zones the content items render? I know widgets can easily be placed in different zones in a page, and I'm wondering if there is a similar functionality for content items? Say you create a Page content item, or any other content item, that item is always rendered in the main-content zone, more precisely:

@if (Model.Content != null)


 <div id="main-content">                 




But what if I want the content item, say in this case the event content type from the orchard tutorial, to render in a different top level zone, like 'TripelFirst' or TripelSecond? Is this possible? 

Apologies if I'm asking an elementary question, but I've been trying to fully understand Orchard for a while and a few minor mental blocks bugging me. 


Thanks for any help.

Sep 11, 2012 at 11:32 AM

I'm not sure I know of a way to do exactly what you are asking, but is placements not enough? So just move the parts you want to render to the places you want?

New to Orchard 1.5 is the ability to render parts of your contentItem in any Zone using placements. So:

<Match ContentType="MyType">
   <Place MyFirstPart="/AsideSecond:1" />
   <Place MySecondPart="/Header:1" />
   <Place MyThirdPart="-" />

Would this be sufficient? 

Sep 11, 2012 at 12:44 PM

Thanks, that seems to be exactly what I'm looking for, for some reason I was under the impression that placements can only be used to place parts inside local zones only, I didn't know you could reference top level zones in Sorry for being so obtuse, but another question where exactly do I put that In my theme? I'm following the orchard tutorials on creating custom types (the Event tutorial) and adding a Map part to it (the writing a content part tutorial). After adding the map part, how would I control where the map part is rendered inside the Event content type? Do I specify this inside the content items 


Again thanks a million for your help, greatly appreciated.

Sep 11, 2012 at 12:57 PM
Edited Sep 11, 2012 at 12:58 PM


No worries man, Orchard is beast. I secretly believe no one fully understands its vast array of capabilities and features. But once you get your head around the basics it is awesome. And you were under the correct impression that you could only place stuff in the content items zone, since that was the case before, it has recently been upgraded and made super awesome. It still has a few little bugs, but I'm sure they will be ironed out soon enough. 

You can place the file in your module. So you would have this in your Maps module placement file:


    <Place Parts_Map="/AsideSecond:10"/>
    <Place Parts_Map_Edit="AsideSecond:7.5"/>


This would always place the MapPart in the aside second regardless of which content type you add it to. If you want to have it in the AsideSecond for most content types, but in the Header for your Events content type you would have this:


    <Place Parts_Map="/AsideSecond:10"/>
    <Place Parts_Map_Edit="/AsideSecond:7.5"/>

    <Match ContentType="Events">
       <Place Parts_Map="/Header:2"/>
       <Place Parts_Map_Edit="/Header:1"/>


And file can also go in your theme. This would probably be best really, as the themes will override your modules placement. So module should have a generic placement, and your theme would be more site specific. If you see what I mean. Hope that helps.

One more thing, if you are just starting out and want to get your head around it all, I would recommend following this superb guide to building your first module by sfmskywalker: . This coupled with the to look up things you don't quite understand, you should be flying high and creating your own awesome modules in no time.

Sep 11, 2012 at 1:16 PM

Absolutely awesome explanation. 

Sep 13, 2012 at 1:14 PM

I'm glad this was added in Orchard 1.5. I spent a bit of time writing custom code to do this a few months ago. Hopefully I'll get to go back and edit those use instead. 

Sep 13, 2012 at 1:39 PM

Yeah, I mean it wasn't too bad before, you just had to write your own mini areas to render stuff in. But is always more effort and this way is just awesome. And I always mean to go back and change things but well, I always seem to run out of time for those kind of useful tasks. I still have a couple of sites running on 1.3. It makes me sad. I'm looking forward to more awesome features in the future :D