Page 1 of 1

Changing themes based on date/time

Posted: Wed Jan 09, 2013 5:44 am
by joni.nousiainen
Hi!

My company is currently evaluating Broadleaf's suitability for a customer's e-commerce site. One of their requirements is "possibility to change UI's theme on date/time (e.g. different theme during Xmas)". My first guess after a brief glimpse at the documentation is that this could be achieved by either 1) creating different Thymeleaf templates for each theme and selecting the correct one by using a custom BroadleafThymeleafViewResolver or 2) embedding the logic in the main template.

Has anyone implemented similar feature with Broadleaf before? Suggestions on which path (1 or 2) would be better, and why? Are there any other options? Thanks in advance!

BR,
Joni

Re: Changing themes based on date/time

Posted: Wed Jan 09, 2013 11:29 am
by phillipuniverse
I have not heard of anyone doing what you described. However, I think the first option would be best as it probably simplifies your templates considerably.

Re: Changing themes based on date/time

Posted: Wed Jan 09, 2013 11:50 am
by phillipuniverse
Talked a little bit with the guys here. There is a component called a Theme Resolver (see the BroadleafThemeResolver interface) that is used by the BroadleafRequestFilter. The intended use of this is for multi-site installations but it might also work in your case as well. You would need to override the blThemeResolver in an application context and have your class impement BroadleafThemeResolver.

This might be a little overkill though as you would have to duplicate your templates for each style. I guess it depends on how different your themes really are. If you are just changing the styling you might just have logic to include different javascript/css files in your main template file.

Re: Changing themes based on date/time

Posted: Mon Jan 14, 2013 4:13 am
by joni.nousiainen
The requirement isn't a 100% clear yet. My guess is that choosing CSS/JS in the template is probably enough. But it's good to know that there is the other option if a more hard core solution is needed. Thanks for the advice!