Jul 20, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)

free web hosting

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

Amezis
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 smile.gif

Reply

palladin
QUOTE(Amezis @ Jul 1 2005, 12:42 PM)
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 smile.gif
*



Got in php, writing from memory smile.gif

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

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 smile.gif if not work write cool.gif

 

 

 


Reply

snlildude87
What you need is a PHP style switcher. I searched for that yesterday, and I'm planning to implement it for my site. http://alistapart.com/articles/phpswitch/. A List Apart is a great site for tutorials on web development.

Have fun!
http://sang.trap17.com/

Reply

Amezis
QUOTE(palladin @ Jul 1 2005, 03:29 PM)
Got in php, writing from memory smile.gif

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

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 smile.gif if not work write  cool.gif
*



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?

Reply

bjrn
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:
CODE
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : multiple css


    Looking for multiple, css, time

Searching Video's for multiple, css, time
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE