#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    6
    Rep Power
    0

    Unhappy Css / skin / template Help!


    I have 3 remotely hosted css files. These are basically my themes. I want a user to be able to select a theme, by an 'a href' link on my sidebar. How do i do this in Php code? I also want a defualt theme, but still allow the user to change it.....

    Thank you!

  2. #2
  3. Second highest poster :p
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2001
    Posts
    7,322
    Rep Power
    33
    How is this thread different to your existing one?

    http://forums.devshed.com/t79713/s.html
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    6
    Rep Power
    0
    Originally posted by a.koepke
    How is this thread different to your existing one?

    http://forums.devshed.com/t79713/s.html

    I said that it'd worked there so people wouldn't post a message. thats why i made a new one.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    25
    Rep Power
    0
    http://noxiousneo.fragism.com/v2/index.php?f=1

    works fine for me....

    what's wrong for you?

    -Nay
  8. #5
  9. No Profile Picture
    =) wannabe?
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2002
    Location
    florida
    Posts
    2,153
    Rep Power
    15
    i deleted this one =D look to the next one.
    Last edited by wannabe; August 28th, 2003 at 11:22 AM.
  10. #6
  11. No Profile Picture
    =) wannabe?
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2002
    Location
    florida
    Posts
    2,153
    Rep Power
    15
    http://jerriko.net/template_change.php

    that's the working example. hurry up and check it out =D cause it's not hosted on my server. and it's in the root dir. guy's gonna be pissed =D.

    here are the files i used

    -- temlate_change.php - name of this one doesnt matter



    PHP Code:
    <?
    // if $_GET['a'] equals 'change' then set $form, else set $form to empty.

    if ($_GET['a'] == 'change')
    {

        
    $form '<form action="change.php" method="post">
    <SELECT name="template">
    <option value="default">default</option>
    <option value="1">template 1</option>
    <option value="2">template 2</option>
    </SELECT>
    <input type="submit" value="choose" /></form>'
    ;


    }else{

        
    $form '';
    }


    // define valid templates

    $templates = array('1' => 'template1','2' => 'template2');

    // if cookie exists and the key exists in $templates array then set $cssfile. else make $cssfile to default

    if (isset($_COOKIE['template']) && array_key_exists($_COOKIE['template'],$templates))
    {

           
    $cssfile $templates[$_COOKIE['template']];
    }else{
           
    $cssfile 'default';
    }


    ?>

    <html>
    <head>
    <title>testin css</title>

    <link rel="stylesheet" type="text/css" href="<?=$cssfile?>.css">

    </head>

    <body>
    <table width="200" height="200" class="table">
    <tr>
    <td>this is a table</td>
    </tr>
    </table><br>

    <?=$form?>
    <a href="<?=$PHP_SELF?>?a=change">change template</a>

    </body>
    </html>

    ------------------------------

    -- change.php - this one does the changing. it must be that name and separate file. since cookies arent applied until next page view =D u'll understand later.


    PHP Code:

    <?

    // if $_POST['template'] exists and isnt empty then set cookie.

    if (isset($_POST['template']) && $_POST['template'] != "")
    {
            
            
    // set cookie

           
    setcookie('template',$_POST['template'],time()+3600*24*365);

    }

    // redirect
    header("Location: template_change.php");


    ?>
    then i used

    -- default.css


    code:--------------------------------------------------------------------------------
    .table {background-color: #00eeff;}
    --------------------------------------------------------------------------------


    ------------------

    template1.css, template2.css
    those have the same line as default.css
    only color changes

    i mean you could have a different page for the template choices. so they can preview before using and the form stays there all the time. but that's more complicated =D

    goodluck
    Last edited by wannabe; August 28th, 2003 at 11:25 AM.

IMN logo majestic logo threadwatch logo seochat tools logo