JNdev Posted November 17, 2016 Report Posted November 17, 2016 I have this code but not work and place on client controller, suggestion from my friend naja7 aka @Blesta Addons I mean can switch theme from browser Eg domain.com/?theme=bootstrap-1, domain.com/?theme=bootstrap-2 etc /*===================== Theme Switcher ========= */ $style = null; $stylesArr = array('bootstrap', 'theme-1', 'theme-2', 'theme-3'); // Get from URL as override if(isset($_GET['theme']) && isset($stylesArr[$_GET['theme']])) { $style = 'client/' . $_GET['theme']; } // Fallback condition Set Default Theme if (empty($style)) { $style = 'client/bootstrap'; //Set Back To Default Theme } // Get from cookie if(isset($_COOKIE['theme']) && isset($stylesArr[$_COOKIE['theme']])) { $style = 'client/' . $_COOKIE['theme']; } // Update cookie $expiration = time() + 60 * 60; // Expire in 1 hour setcookie('theme', $style, $expiration); // Set Theme For Blesta $this->setDefaultView($style); /* =================== Theme Switcher ========= */ All help are welcome and greatly appreciated Quote
Blesta Addons Posted November 18, 2016 Report Posted November 18, 2016 Hello try this code . Open app/client_controller.php under parent::preAction(); add the fallowing code /*===================== Theme Switcher ========= */ if (!isset($this->Session)) { Loader::loadComponents($this, ["Session"]); } if (isset($_GET['switcher']) ) { $this->Session->write("blesta_theme", $_GET['switcher']); } if ($this->Session->read('blesta_theme')) { $theme = $this->Session->read('blesta_theme'); // Set the THEME $this->setDefaultView("client/". $theme); } /* =================== Theme Switcher ========= */ JNdev and Michael 2 Quote
JNdev Posted November 18, 2016 Author Report Posted November 18, 2016 Wow, it works well with if (!isset($this->Session)) { Loader::loadComponents($this, ["Session"]); } Thank you sir naja7, this is very helpful to me, although it can not be on all pages. Michael 1 Quote
Blesta Addons Posted November 18, 2016 Report Posted November 18, 2016 On 18/11/2016 at 6:35 PM, Jawanet said: Wow, it works well with if (!isset($this->Session)) { Loader::loadComponents($this, ["Session"]); } Thank you sir naja7, this is very helpful to me, although it can not be on all pages. Is only limited to client pages and maybe also for logged in client only . but if blesta make the theme set via configure , then it will be available for all . Quote
JNdev Posted November 20, 2016 Author Report Posted November 20, 2016 Yes this been quite helpful, at least a get to see more views . And give back the spirit to develop more theme Blesta Addons 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.