If I have lets say four different themes and I want to switch the themes with a link on my front-end (like /?theme=theme1), how can i realize that with SilverStripe 4?
In SilverStripe 3.6 I could jut use code in my _config.php like:
$theme="";
if (array_key_exists('theme', $_GET)) {
$theme=$_GET['theme'];
}
SSViewer::set_theme($theme);
I googled for hours now and found that I should use something like:
First things first. If it’s not already, make sure your site is in dev mode (SS_ENVIRONMENT_TYPE=dev in your .env file) - that will help with debugging, since it will show you errors.
The error may be something as simple as a missing use statement from the file you’re working on. Since the Config class exists in a specific namespace, you’ll need to tell PHP where to find it: