1

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.

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
Rahatur
  • 3,147
  • 3
  • 33
  • 49
  • There is nothing like configuration of different themes on different pages in nopCommerce – Divyang Desai Aug 28 '16 at 03:38
  • Well I am not looking for any configuration. I plan to do with customization. But how do you apply that and where? – Rahatur Aug 28 '16 at 07:19
  • Yeah, incase if anyone from the nopCommunity knows the answer. I guess its not wrong to post on multiple forums. – Rahatur Sep 06 '16 at 00:17

1 Answers1

3

It should be possible following these steps:

  1. Create a new plugin.
  2. Copy the current class ThemeContext, implementing IThemeContext to your plugin. Use a different name to avoid mistakes (see).
  3. Register the new class with Autofac. Set a higher priority to ensure that the new class replaces the old ThemeContext. Enable the plugin and check it works by setting a breakpoint there.
  4. Change the get part of the property WorkingThemeName in your new class and implement any business rules you need, returning the alternate theme name when appropriate. You may need to access the current RouteData to get the current route controller or parameters for each http request.

That's all. It is easier than it looks.

Marco Regueira
  • 1,045
  • 8
  • 17
  • This sounds good. Will give it a try. Just wondering if there is any way to do the job completely from the plugin without altering anything on the nopCommerce. – Rahatur Sep 06 '16 at 00:19