Dynamic Theme Selection in Orchard Core CMS

Using a Custom Orchard Core CMS Module

While developing a new Orchard Core CMS Module I thought about dynamic theme selection in Orchard Core CMS. In the current version of Orchard CMS the administrator has the ability to preview the website using a different theme during his or her active session without changing the current theme on the website. This is a really awesome feature thankful to Orchard's support for theme selectors, which "negotiate" which theme will be displayed to the visitor at any given time based on priority. Normally this is always the currently selected theme when on the frontend or the admin theme when navigating the backend, but features can be developed to change the current theme based on culture, time of day, user role, at random, etc.

For fun, I created a module in Orchard Core that allows an administrator to change the current theme for his or her session by passing in the name of the theme using a query string parameter. When the administrator appends ?theme={theme name} into the URL, that theme will become the currently active front-end theme for the session until he or she changes it to another theme or clears the session.

Dynamic Theme Selection Module for Orchard Core CMS

So, if I am an administrator (could be based on permissions, too) of the website and the module is active, I can dynamically activate any enabled theme during my session using the theme query string parameter.

...?theme=TheAgencyTheme to activate The Agency Theme

...?theme=TheBlogTheme to activate The Blog Theme

I can think of a number of ways to enhance the user experience, but I'll save that for another time.

Always fun to develop new modules and themes for Orchard Core CMS!