Hi all, someone has explored the option to have m...
# general
g
Hi all, someone has explored the option to have multiple frontend themes in a Solidus project. The idea is to allow the admin to change the theme or at least to be able to switch the theme per project in the code and do an assets compilation. I’m thinking of using the new Solidus starter theme.
k
Can I ask why they need to change the theme via admin? Do you have a multi-domain setup, or something similar?
g
@kennyadsl, yes, we have a multi-domain app. At this moment we modify the theme attributes by using CSS variables and we will like to have the option to have different full themes.
k
I think it’s definitely possible by using some built-in Rails features like
ViewPath
. You can create a new preference on the store model, let say
preferred_theme
and set it in the storefront controller with a before_filter that does:
Copy code
prepend_view_path("themes/#{current_store.preferred_theme}")
in the
themes
folder, just replicate what you see in
app/views
, and that will take precedence over the default views that are rendered.
g
Looks simple and will give us flexibility. I will test it. Thanks for your help.
🙏 1