I was wondering how we can activate different themes on different pages dynamically. For example few pages will have theme-1 and rest of the site will have theme-2. Users will not be selecting the themes. It will have to be set dynamically from the back end.
One way is to have separate master pages.
But is it possible that we have two nopCommerce themes and we activate any one dynamically on different pages of the same store? Not multi store.
It should be possible following these steps:
ThemeContext
, implementingIThemeContext
to your plugin. Use a different name to avoid mistakes (see).ThemeContext
. Enable the plugin and check it works by setting a breakpoint there.get
part of the propertyWorkingThemeName
in your new class and implement any business rules you need, returning the alternate theme name when appropriate. You may need to access the currentRouteData
to get the current route controller or parameters for each http request.That's all. It is easier than it looks.