Strip widget wrappers based on certain conditions

Topics: Customizing Orchard, General, Installing Orchard, Troubleshooting, Writing modules, Writing themes
Mar 29, 2011 at 11:27 AM
Edited Mar 29, 2011 at 11:27 AM


What would be the best way to get rid of/modify widget wrappers under certain conditions eg. for specific widget type. Wrapping in <article> is not always the best option.  I see a couple of ways, but I'm not sure which one would be the best in terms of best-practice:

  1. Modify the "Widget_Wrapper" shape - add an alternate (eg. Widget_Wrapper__<content_type_name>)
  2. Modify the "Widget" shape - remove wrapper from the ShapeMetadata.Wrappers collection in OnDisplaying event when conditions are met
  3. Some other ways?

I'd rather go with the 1. approach, but maybe there are better solutions?

Thanks in advance! Piotr


Mar 29, 2011 at 9:40 PM

1. not possible: wrappers are not shapes.

2. yeah, worth trying.

Mar 29, 2011 at 10:54 PM

I'll vote for making wrappers ordinary shapes in 1.2:) Did it differently - overrode the Widget.Wrapper.cshtml shape file and placed a switch statement inside. Not the best option though, but simple and without much mess.

Mar 29, 2011 at 11:25 PM

Please feel free to file a suggestion.