mww / baptiste style switcher doesnt work in CMSMS v1.1
Posted: Tue Aug 14, 2007 5:34 pm
Hi all,
I always used to make use of the style switching solution made by the forum user "mww", and further modified by forum user "baptiste" (posted below - thanks guys!), but it doesn't seem to work now that I have upgraded to version 1.1 - I think it has something to do with PHP5 and the use of the "foreach" function in the "switcher.php" file, but that's just guess work as I'm not particularly hot on PHP these days!
Could someone with a little more skill take a look at this? It used to work like a dream to switch between different style sheets... I can't really use a java one because all the java switchers I have found make use of external css files, and i need to reference and switch between the css templates through the CMSMS admin, as the person I'm making the site for will want to make changes to the CSS here and there and wants to do so through the CMS; clients eh?! I've posted the solution developed by mww and baptist below, any assistance or new solutions would be greatly appreciated!
There are just 3 places that you need to make changes to the code below :
In '1)' below, change the menu 'set' values to your values, you don't need to change 'default', this option just deletes to cookie, but the other values need to be the names of your stylesheets.
In '3)' below change the acceptable styles to match those in '1)' above.
In '3)' below change the server to be your server name.
And add stylesheets to match your options!
I've probably forgotton something really basic, but here's the stuff :
1) Create a user defined tag to write the menu to the page:
- Extensions » User Defined Tags » Create User Defined Tag: accessibility_menu
- Add to your template as '{accessibility_menu}'.
/***********************************************
* Writes the accessibility menu
************************************************/
echo "";
echo "Accessibility Options
";
echo "Default Text/Colour";/*ADD YOUR OPTIONS HERE*/
echo "Larger Text";
echo "Colour option 1";
echo "Colour option 2";
echo "";
2) Create a user defined tag to write the selected css links in the page:
- Extensions » User Defined Tags » Create User Defined Tag: set_css
- Add to the 'head' section your template as '{set_css}'.
/***********************************************
* reads a cookie to get values for the accessibility options
* these are stored in an array in the cookie as:
* sitestyle('default', 'larger', 'colour_option1') etc...
************************************************/
if(isset($_COOKIE['sitestyle'])){
foreach($_COOKIE['sitestyle'] as $style) {
$css_tag = "";
echo $css_tag;
}
}
3) Create a file called 'switcher.php' in your website document root and paste the following in to it:
/************************ End of Code *************************/
Questions welcome.
I always used to make use of the style switching solution made by the forum user "mww", and further modified by forum user "baptiste" (posted below - thanks guys!), but it doesn't seem to work now that I have upgraded to version 1.1 - I think it has something to do with PHP5 and the use of the "foreach" function in the "switcher.php" file, but that's just guess work as I'm not particularly hot on PHP these days!
Could someone with a little more skill take a look at this? It used to work like a dream to switch between different style sheets... I can't really use a java one because all the java switchers I have found make use of external css files, and i need to reference and switch between the css templates through the CMSMS admin, as the person I'm making the site for will want to make changes to the CSS here and there and wants to do so through the CMS; clients eh?! I've posted the solution developed by mww and baptist below, any assistance or new solutions would be greatly appreciated!
There are just 3 places that you need to make changes to the code below :
In '1)' below, change the menu 'set' values to your values, you don't need to change 'default', this option just deletes to cookie, but the other values need to be the names of your stylesheets.
In '3)' below change the acceptable styles to match those in '1)' above.
In '3)' below change the server to be your server name.
And add stylesheets to match your options!
I've probably forgotton something really basic, but here's the stuff :
1) Create a user defined tag to write the menu to the page:
- Extensions » User Defined Tags » Create User Defined Tag: accessibility_menu
- Add to your template as '{accessibility_menu}'.
/***********************************************
* Writes the accessibility menu
************************************************/
echo "";
echo "Accessibility Options
";
echo "Default Text/Colour";/*ADD YOUR OPTIONS HERE*/
echo "Larger Text";
echo "Colour option 1";
echo "Colour option 2";
echo "";
2) Create a user defined tag to write the selected css links in the page:
- Extensions » User Defined Tags » Create User Defined Tag: set_css
- Add to the 'head' section your template as '{set_css}'.
/***********************************************
* reads a cookie to get values for the accessibility options
* these are stored in an array in the cookie as:
* sitestyle('default', 'larger', 'colour_option1') etc...
************************************************/
if(isset($_COOKIE['sitestyle'])){
foreach($_COOKIE['sitestyle'] as $style) {
$css_tag = "";
echo $css_tag;
}
}
3) Create a file called 'switcher.php' in your website document root and paste the following in to it:
/************************ End of Code *************************/
Questions welcome.