Creating multiple frontend designs for a Laravel website: How to implement and switch between them?

Hey everyone,

I’m working on a Laravel project and I want to give users the ability to choose between different frontend designs. To be clear, I’m not talking about Laravel’s blade templating system, but actual HTML/CSS templates.

My plan is to have a settings page where users can pick their preferred design. But I’m not sure how to set this up properly. Should I create separate folders for each design? How do I dynamically load the right one based on the user’s choice?

Also, I’m wondering about the best way to store and retrieve the user’s preference. Should I use the database or would sessions be a better option?

If anyone has experience with this kind of feature, I’d really appreciate some guidance on how to approach it. Thanks in advance for any tips or suggestions!

yo sophia, try using separate folders for each template. a middleware can check user pref (maybe stored in the database) to load the right assets. this keeps things manageable.

hey sophia39, have u tried laravel view composers for injecting the chosen design? a middleware for design selection might work too. what type of site are u building? curious how many designs ya plan to offer?

Implementing multiple frontend designs in Laravel can be approached efficiently. Consider creating a themes directory in your public folder, with subdirectories for each design. Use a middleware to check the user’s preference and set the appropriate theme. Store this preference in the database for persistence across sessions.

For dynamic loading, you could use a custom Blade directive to include theme-specific CSS and JavaScript files. This approach allows for easy scalability as you add more designs. Remember to create a fallback mechanism to a default theme if a user’s chosen design becomes unavailable.

Testing thoroughly across different designs is crucial to ensure consistency in functionality. Also, consider performance implications of loading different assets for each theme.