I put together something, but it’s not restricted to ModX....
Basically you put a link on the page, linking back to the same page, adding a variable.
The "[~[*id*]~]" syntax is really handy here, so we have something like this...
<a href="[~[*id*]~]?user_style=0">User Style 0</a>
The I put code in the header.
The code looks for the variable in the url.
If there is a variable it uses it to choose a "font style" or whatever, and sets a cookie.
If there is no variable, it looks for a cookie, if no cookie, uses default "font style" or whatever.
So if the person browsing the site has cookies enabled, the "font style" or whatever will remain constant. If the person doesn’t have cookies enabled, only the first page will change after the request, then back to default.
Here’s the code for the header of the template..
<?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 there is a cookie set user_style to cookie user_style
}else{
$user_style = 0; // if not use default
}
};
$modx->setPlaceholder(user_style, $user_style);
?>
Then you use that variable to change font style...
<?php
echo '<style type="text/css">';
echo 'body{';
if($user_style == 0){
echo 'font: large;';
}else{
echo 'font: small;';
}
echo '}';
echo '</style>';
Hope this helps. It’s works for me, although it’s not really integrated into the ModX framework, so to speak. I’ll be interested to see if there are any other methods around to achieve this.