This project is read-only.

Can I dynamically place widgets in different zones?

Topics: Customizing Orchard, Writing themes
Dec 14, 2012 at 6:10 AM

What would be the best way to accomplish the following.

-Customer logs in using a PC, the menu is in aside-first and Widget "B" is in Aside Second

-Customer logs in on a tablet, the menu is places in the Navigation zone and Widget "B" moves out of Aside Second and moves to After Main.

I have seen where you can switch themes dynamically, but I'm not sure if that allows you to move widgets around into different zones or not....






Dec 14, 2012 at 1:33 PM

Maybe you could define a layer that is active when users are logged in from PC, and then another for when they're visiting from a tablet? Publish the widget to both layers, but the rules of the layers would ensure that they are never both active at the same time. I haven't really used widgets or created custom rules for them so I'm not sure if there's any reason that wouldn't work. 

Somewhat related, I have programmatically created shapes and pushed them to specific zones:




You could adapt this to check for the condition you want (PC/tablet) and push to the appropriate zone. 

Dec 14, 2012 at 5:01 PM

Thanks for the tips. I'll give both ideas a shot and see what works best for me.