Homepage
Main navigation
Main content
Additional information
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Winter CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
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](https://github.com/Hounddd/wn-themeswitcher-plugin) plugin. ```twig title = "Theme switch" url = "/switch-theme" layout = "default" is_hidden = 0 == <?php 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([ 'first-theme-code', 'other-theme-code', ]); */ $currentThemeKey = $themes->search(Theme::getActiveThemeCode()); $nextThemeKey = $currentThemeKey +1; if ($nextThemeKey > $themes->count() -1) { $nextThemeKey = 0; } $nextTheme = $themes->only($nextThemeKey)->first(); Theme::setActiveTheme($nextTheme); return Redirect::to('/'); } ?> == ``` If only two themes are defined, the page behaves like a "theme switcher".
References
Add additional online resources to your trick
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline