This project is read-only.

ShapePartialResult from Controller issue

Topics: Customizing Orchard
Sep 6, 2013 at 10:29 PM
Hi, I implemented a controller that returns a ShapePartialResult in order to render an existing Menu as a Shape Menu Item. The strange thing is, it only works correctly when ShapeTracing is enabled.

The shape (MegaMenu) renders the menu like this:
@Display(Html.Action("GetMegaMenu", "MegaMenu", new { menuTitle = "MegaMenu", area = "MyTheme.Bootstrap" }))
The controller does a bunch of work to create a shape which is instantiates like this:
            dynamic menuShape = _shapeFactory.Create("Menu");


            NavigationHelper.PopulateMenu(_shapeFactory, menuShape, menuShape, menuItems);

            return new ShapePartialResult(this, menuShape);
And the menu template (Menu-mega-menu) wraps the child contents thus:
 var tag = Tag(Model, "div");
So, the issue I'm seeing is the first element in Menu.cshtml or an alternate is being stripped. In the case above, the div is stripped and my menu doesn't display correctly as a menu item. If I use default Menu.cshtml, , <nav> is the first element, and it's stripped. And if I insert a "decoy" div before @tag.StartElement, it gets stripped and I'm left with the desire results.

My decoy solution is an unacceptable hack, and I'd like to figure out if I'm doing something wrote, or stumbled across a bug. Thanks!

Sep 7, 2013 at 1:44 AM
I don;t think that shape should be named "Menu".