Results 1 to 6 of 6

Thread: CSS switching

  1. #1
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default CSS switching

    I just started learning CSS and i want to know one thing:

    Lets say that i have like 3 totaly diferent .css (for simple example one has a red background, other has black, and the 3rd has a yellow background collor).

    And lets say that a visitor can pick one of three themes (.css), and during his session every page will load with that .css. The same thing is with languages.

    How do i do that.

    I would be grateful for beginner-frendly explanation, but any explaantion will do as long as there is one.

    Thank you for your time.

  2. #2
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    add theme variable to your sql table where you register all links and set first value to theme1.css. Then he can change this value by pushing button with UPDATE querry in you webpage.
    Also you will need session to get his theme variable and include it to your
    <link rel="stylesheet" type="text/css" href="../<?php include $theme?>" />
    HTH

  3. #3
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes that is helpfull, but i'm looking for more database independent and more cookie approach.

    For example i have a site that doesn't have a database, but a have cookies, and when you visit my site I give you a cookie with the session time and stuff, when you change the theme i send you cookie, so next time you visit my site i read the data on cookie and change the theme according to that, and if a cookie expired or there is none i just load default.css for example. Now the question is how do i do that in html or whatever

  4. #4
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    what cookie do you have to store theme?

  5. #5
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by auriaks View Post
    what cookie do you have to store theme?

    I won't store theme on a cookie, i will store some value like ccsId=0 or ccsId=1 and when the page loads up somehow i want html to read the value and load an appropriate external css.

    something like
    [pseudo code]

    if(ccsId==1)
    load
    css1.css
    else
    load
    cssDefault.css
    [/pseudo code]





    I am sorry if I'm not making this clear enough, i lack sufficient knowledge

  6. #6
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    ok, but how you will get your pseudo code? (ccsId)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •