Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Website theme switcher by URL

by DamsFX, last modified on October 3rd, 2023

This page, if duplicated across themes, allows you to cycle between them. It is possible to limit the themes available for this loop (see comment note).

Take care : This affects the whole website (as it override the site config), not just the current user visiting the page. If you want a more powerfull solution take a look at : Hounddd.ThemeSwitcher plugin.

title = "Theme switch"
url = "/switch-theme"
layout = "default"
is_hidden = 0
    function onStart()
        use Cms\Classes\Theme;
        use Redirect;

        $themes = collect(array_pluck(Theme::all(), 'dirName'));
         * Use the above syntax to limit the availaibles themes
         * to those specified
        $themes = collect([

        $currentThemeKey = $themes->search(Theme::getActiveThemeCode());

        $nextThemeKey = $currentThemeKey +1;
        if ($nextThemeKey > $themes->count() -1) {
            $nextThemeKey = 0;

        $nextTheme = $themes->only($nextThemeKey)->first();

        return Redirect::to('/');

If only two themes are defined, the page behaves like a "theme switcher".



We use cookies to measure the performance of this website. Do you want to accept these cookies?