This project is read-only.

Alternate Widget Wrapper

Topics: Customizing Orchard
Jun 20, 2011 at 1:22 PM


There are a few posts on this but I am new to Orchard and am having trouble finding a solution.

I would like to be able to provide an alternate wrapper to widgets, for instance I have implemented a search form in the header which is currently using Widget.Wrapper.cshtml in my current theme, wrapping the form in a section (I edited this for the theme) and applies a heading / footer if required as per the default wrapper.

I have created a Widget-SearchForm.cshtml and have tried to apply control via the to test if the search form can be removed (only for testing to see if anything happened).

<Place Widget__SearchForm="-" />

This did nothing, presumably because the placement only effects elements in the content zone?

To remove the wrapping HTML I have updated the Widget-SearchForm.cshtml to include an update to the Model


Model.Wrap = false;




And updated the Widget.Wrapper.cshtml to check for this and apply unwrapped code.

@if (Model.Wrap != null && Model.Wrap == false)



    /** extra display code removed **/



Is there a better way of applying a wrapper to a widget without effecting all widgets on site?



Jun 21, 2011 at 11:41 PM

Wrappers don't have alternates but it's not quite clear to me why you don't simply alternate the shape itself.

Jun 24, 2011 at 11:59 AM

Do you mean that I would be able to create a shape for a widget (such as the search widget) which would override the default shape and not automatically use the Widget.Wrapper.cshtml?

Whenever I add a widget from the CMS and create a new shape for it the wrapper always seems to be applied.


Jun 24, 2011 at 8:30 PM

Well, substitute the word "template" for "widget" in what you just said. No, the wrapper would still be there. If you want to remove the code the wrapper is producing, I suppose you could remove the wrapper from the Wrappers collection from a handler.

Jan 27, 2012 at 10:49 AM
Edited Jan 27, 2012 at 10:49 AM

Having complete control of the HTML is a key factor when developing websites, As a developer on the front end side, I would like to stay away from digging into code to change the markup. So that (i.e. easier control of the markup) would be a huge feature to me in a future release of Orchard.

Jan 27, 2012 at 5:50 PM

You're just editing HTML templates, they happen to be scriptable so you can use code as well, but you'd find the same with any CMS if you wanted to start changing templates; they all have their own ways of scripting in templates.

Jan 27, 2012 at 5:51 PM
Edited Jan 27, 2012 at 5:58 PM

Actually, to set up alternates and wrappers you only have to edit an XML file:

Edit: Sorry, that was a mistake, it won't work for your scenario. Yes placement only affects positioning of things inside the widget.

But you can still use Shape Tracing to find out a suitable Alternate name for your widget so you can override it appropriately, no coding required. There are other features to help with this as well.

Jan 28, 2012 at 3:26 PM

Scripting in templates, no problem. But I was basically referring to the question about creating alternate wrappers. As I understand it, that is not possible. So the only option would be to make the changes in the view folder of the widgets, which is outside of the theme. Right?