Switching between multiple styles

Discussion in 'PHP' started by rewindd, Oct 21, 2007.

  1. #1
    Hey everyone. I hope this is the right place for this. I have a question about switching through random themes on my site.

    My design on my site is based on a style.css. I have several themes already made (style.css, style2.css, style3.css). Is there a way, using php, or javascript code to make my website automatically switch between these three themes?

    Thanks.
     
    rewindd, Oct 21, 2007 IP
  2. moodswing

    moodswing Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    put refresh timer, can be done with javascript or php
    put random number
    use those numbers to point to each of your styles
    make a php code on this line
    <?php random number code script ?>
    <link href="<?php yourcode to echo the styles?>" rel="stylesheet" type="text/css" />
     
    moodswing, Oct 21, 2007 IP
  3. Grumps

    Grumps Peon

    Messages:
    592
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Moodswing's method should work well but if you apply that to all your pages. It will be a merry-go-round for the user because every different pages would probably have a different style. You probably want some consistency during the user's visit.

    Consider using
    <?php random number code script ?>

    and add those values into cookies/session which expires after 24 hours? So during the next visit, user will be able to experience something else.
     
    Grumps, Oct 21, 2007 IP
  4. rewindd

    rewindd Guest

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hmm, I am sorry, I am a real noob when it comes to randomizing and cookies, i guess. Is there anyway you could provide me a code?

    Basically I have 3 style.css files, and the only place I need to change something to change the look of the whole site is in the index.php in the <link herf part...

    I hope that helps a bit.

    Sorry for the difficulties.
     
    rewindd, Oct 21, 2007 IP
  5. rewindd

    rewindd Guest

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The only thing that really changes on the layout is the colors of the images, and the color of some of the text, but the shape stays intact.
     
    rewindd, Oct 21, 2007 IP
  6. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You could choose a random theme upon their first visit, then use sessions to keep that theme throughout their visit.
     
    matthewrobertbell, Oct 21, 2007 IP
  7. Fl1p

    Fl1p Active Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Fl1p, Oct 21, 2007 IP