More than one theme active at a time - possible?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi,
I was wondering how we can activate a different theme on some pages dynamically.
For example few pages will have theme-1 and rest of the site will have theme-2. Users cannot select the themes. It would be set dynamically.

One way is to have separate master pages. But is it possible that we have two nopCommerce theme and we activate any one dynamically on some pages?
7 years ago
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.
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.
                
For this, you can also refer link
http://stackoverflow.com/questions/39184957/nopcommerce-dynamic-theme-activation-for-different-pages-not-multi-store
and
https://github.com/nopSolutions/nopCommerce/blob/9b4a74dd209935f71bcf00574f8e6283d1d3aaae/src/Presentation/Nop.Web.Framework/Themes/ThemeContext.cs
7 years ago
nayanpatel wrote:
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.
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.
                
For this, you can also refer link
http://stackoverflow.com/questions/39184957/nopcommerce-dynamic-theme-activation-for-different-pages-not-multi-store
and
https://github.com/nopSolutions/nopCommerce/blob/9b4a74dd209935f71bcf00574f8e6283d1d3aaae/src/Presentation/Nop.Web.Framework/Themes/ThemeContext.cs

Yes, Saw that stackoverflow answer. Over there the question was asked by me too :)
7 years ago
Very creative idea. Never thought like that. If it is possible then for article I will use a theme and for pages like(about, contact, terms) I will use a different theme.
7 years ago
nikola_chikos wrote:
Very creative idea. Never thought like that. If it is possible then for article I will use a theme and for pages like(about, contact, terms) I will use a different theme.


Try with creating schedule task that will change active theme after a certain time.
7 years ago
sohel wrote:
Very creative idea. Never thought like that. If it is possible then for article I will use a theme and for pages like(about, contact, terms) I will use a different theme.

Try with creating schedule task that will change active theme after a certain time.

Sohel, changing theme is not an issue. The idea was to have multiple theme active at a time. Some time that is necessary. And the idea behind that is very interesting. I am in the process of implementing it in a plugin. So that when the admin uninstalls the plugin the site falls back to a single theme!
7 years ago
Yes Sohel. I was thinking exactly the same. Let us know the plugin after you develop it. Like the plugin idea. If I use the plugin then I can access both theme and without this plugin I can access only the primary theme.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.