This project is read-only.

Adding widgets dynamically

Topics: Customizing Orchard, Writing themes
Aug 22, 2011 at 2:51 PM

In a custom theme, I'm trying to determine how to dynamically instantiate a widget, adjust some of its properties, and then add it to a particular zone. I'd want this behavior to occur only on a specific layer. Is this possible?

Aug 22, 2011 at 5:15 PM

You can instantiate a specific Shape from any template. Look for the Shape used by the widget you target, find the parameters it needs, then use:

Display.THEWIDGETSHAPE(PARAM1: value1, PARAM2, value2, ...)

It's not creating a widget, but just renders what a widget would render. And it might not work if the widget needs db data.