This project is read-only.

Wrappers around Zone

Topics: Customizing Orchard, Troubleshooting, Writing modules, Writing themes
Apr 17, 2012 at 8:50 PM

Hey All, I am havign a problem with Zone wrappers...

First off, I have a wrapper rendering which is great, but I loose all the Zone html Tags....

I do this to push the wrapper...

    public class Shapes : IShapeTableProvider {
        public void Discover(ShapeTableBuilder builder) {
                .Configure(descriptor => {

The Wrapper zone looks like this..

@using Orchard.Widgets;
@if (AuthorizedFor(Permissions.ManageWidgets)) {
    <div class="widget-control">
        <div class="manage-actions"><a href="#">Edit</a></div>
else {

I have Html being rendered out... like so... (bewlo is jsut an example...)

<div id="content" class="group">
 <div class="widget-control">
  <div class="manage-actions">
   <article class="content-item page">

What I end up missing.....
<div class="zone zone-content">
Any ideas yall?
Apr 17, 2012 at 11:38 PM

That's interesting.. I think I'm trying to do the same, but in another way:

public class Shapes : ShapeDisplayEvents {
        public override void Displaying(ShapeDisplayingContext context)
            context.ShapeMetadata.OnDisplaying(displaying => {
                if (displaying.ShapeMetadata.Type != "Widget") {
                    ContentPart contentPart = displaying.Shape.ContentPart;

                    if (contentPart != null) {



<div style="border:1px solid red;">

This works for me, but I'm going to try your implementation as well.



Apr 17, 2012 at 11:40 PM
Edited Apr 17, 2012 at 11:54 PM

Correction, your approach won't work for me, since I need wrappers around any arbitrary content part shape. But that doesn't mean my approach couldn't work for you :)

Apr 18, 2012 at 5:01 PM

I probably know why you end up with missing


<div class="zone zone-content">


That's because rendering of this div is being done by the zone shape itself. Using @DisplayChildren just displays only the content of the zone, but not the zone itself. On the other hand using @Display(Model) will throw StackOverflowException...

Try doing this like:


.OnCreated(created => {
     var zone = created.Shape;
     zone.Child.Add(created.New.PlaceChildContent(Source: zone));


And then, in your wrapper, instead of using @DisplayChildren(Model) do:



Haven't tried that actually, but should work I guess:)


Apr 18, 2012 at 7:31 PM

Yo Piotr, No dice bro!!! It ends up duplicating everything lol!! :S

Apr 18, 2012 at 7:32 PM

Hmmm What exactly gets duplicated? Contents, or the wrapper markup?

Apr 18, 2012 at 7:50 PM

The contents. The zone renders but all content dups :(