Thank you! I haven’t implemented your solution but its mostly the same.
What I’d done is this:
-Create a snippet "[[phpCSSSWitcher]]"
<?php
if(isset($_GET[user_style])) // if user_style has been requested by the user in the url
{
$user_style = $_GET[user_style]; // define user_style
setcookie("user_style",$_GET[user_style],time() + (86400 * 30), "/", "", 0); // set cookie for 30 days
}else // else if there is no user_style variable in the url
{
if(isset($_COOKIE['user_style'])) // see if there is a cookie
{
$user_style = $_COOKIE['user_style']; // if so set user_style to cookie user_style
}else{
$user_style = 0; // if not use default
}
};
$path = '<link rel="stylesheet" href="[(base_url)]assets/templates/css/';
switch($user_style){
case 0:
$path = $path.'site1.css';
break;
case 1:
$path = $path.'site2.css';
break;
}
/** Complete the link and echo its html code **/
echo $path.'" type="text/css"/>';
?>
-Create the links to let the user choose the template. For this I have a chunk called at the top of all documents
<a id="selectEstilo" href=[~[*id*]~]?user_style=0>Oscuro</a>
<a id="selectEstilo" href=[~[*id*]~]?user_style=1>Claro</a>
- Between the tags <head> of the template I call the snippet "[[phpCSSSWitcher]]"
As you can see is the same of yours, but grouped in just one snippet.
Hope this help others, and thanks again!!
NOTICE: Change the paths and styles to your fits