Jump to content
xisto Community
Sign in to follow this  
Amezis

How Can I Have Multiple Css? But only one used at the same time?

Recommended Posts

Well, the title and description wasn't that good.I need to know a HTML/PHP/JavaScript/CSS code that can change the CSS used for my site.Instead of using the defaut CSS style, the user can select another style instead of the default one, which will be used on all pages that have the code, and be remembered by using cookies. So, next time the user visit my page, it will load the CSS file the user choosed last time. If it can't find anything in the cookies, it load the default one.Hope you understand what i'm looking for, and I hope you can help :unsure:

Share this post


Link to post
Share on other sites

Well, the title and description wasn't that good.

 

I need to know a HTML/PHP/JavaScript/CSS code that can change the CSS used for my site.

 

Instead of using the defaut CSS style, the user can select another style instead of the default one, which will be used on all pages that have the code, and be remembered by using cookies. So, next time the user visit my page, it will load the CSS file the user choosed last time. If it can't find anything in the cookies, it load the default one.

 

Hope you understand what i'm looking for, and I hope you can help :unsure:

156766[/snapback]


Got in php, writing from memory :D

 

for: http:\somepage.php?style=1

somepage php.code<head><?php$style = 1;if ( isset($HTTP_GET_VARS['style'])) {$style = intval($HTTP_GET_VARS['style']);}if ($style == 1) {print "<link href=\"styles1.css\" rel=\"stylesheet\" type=\"text/css\" />"}if ($style == 2) {print "<link href=\"styles2.css\" rel=\"stylesheet\" type=\"text/css\" />"}?><head>

Try this :D if not work write :D

Share this post


Link to post
Share on other sites

Got in php, writing from memory :unsure:

 

for: http:\somepage.php?style=1

somepage php.code<head><?php$style = 1;if ( isset($HTTP_GET_VARS['style'])) {$style = intval($HTTP_GET_VARS['style']);}if ($style == 1) {print "<link href=\"styles1.css\" rel=\"stylesheet\" type=\"text/css\" />"}if ($style == 2) {print "<link href=\"styles2.css\" rel=\"stylesheet\" type=\"text/css\" />"}?><head>

Try this :D if not work write  :D

156781[/snapback]


Ok, I'm gonna test that one out. But does it save your preferences? If the user chooses style2, will it open with style2 next time too?

Share this post


Link to post
Share on other sites

No, you'd have to set a cookie for the preferences to be saved (as long as the user accepts cookies and doesn't delete them).

Just set a cookie storing the preferences after each if statement. Something like:

setcookie("Style", $style, time()+3600);

And of course add an if-statement to check if a cookie is set, and if so (and they are not changing their choice) set the style to the one stored in the cookie.

More info on cookies: http://php.net/manual/en/function.setcookie.php

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.