Website themes using CSS and PHP

Discussion in 'Desktop Customisation' started by chris, Aug 12, 2003.

  1. chris

    chris Free to Fly

    Messages:
    1,109
    I have seen dotted about sites that use php to select which css stylesheet is loaded, giving the visitor the option of changing the theme of the page.

    does anyone use this? i have a sort of idea how this could be done i was just wondering if there was anyone already using something like that
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Sounds geh.
    PHP:
    <?php
    switch($css) {
    case 
    blue:
    $css "blue.css";
    setcookie ("3nigmaTheme""blue.css"time()+3600*24*30*12*10);
    break;
    case 
    white:
    $css "white.css";
    setcookie ("3nigmaTheme""white.css"time()+3600*24*30*12*10);
    break;
    default:
    $css "white.css";
    break
    }
    ?>
    //site code here
    <?php
    if (!$_COOKIE['3nigmaTheme']) { 
      print 
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css\" />";
     } else {
      print 
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"$_COOKIE[3nigmaTheme]\" />";
     }
    }
    ?>
     
  3. chris

    chris Free to Fly

    Messages:
    1,109
    knew i could count on you mate, cheers :D
     
  4. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    No problem, the top part needs to be at the very top (so it can set the cookie.. which lasts for 10 years btw :p as there is no method to set a permenant cookie) and the second part can go anywhere as long as it's within the head tags
     
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    heh damn SPeedY_B beat me to it

    oh yeah and wewt the PHP tags work properly in Firebird
     
  6. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Noticed that too, must be the new vB build, hurah hurah and so forth :)
     
  7. NetRyder

    NetRyder Tech Junkie Folding Team

    Messages:
    13,256
    Location:
    New York City
    Nice! ;)
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Personally my site uses different HTML pages and different CSS, this way you can dynamically load the entire site creating it part by part and then using the template parts to build a totally dynamic page.
     
  9. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    http://geffychan.co.uk/index.phps

    how my frontpage works, I will be making a sanitised version of the page include files in the next few days, mine is the less complex way of going about it I think