+ Post New Thread
Results 1 to 4 of 4
Web Development Thread, CSS Style Switcher in Coding and Web Development; I have 3 styles which could be applied to a web page, I want users to be able to change ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30

    CSS Style Switcher

    I have 3 styles which could be applied to a web page, I want users to be able to change the style depending on which style they prefer and save the setting to a file (E.g. Not cookie based).

    User Selects Theme -> Selection written to file --> User visits the site again and the theme selected is displayed again

    Any help appreciated - Preferrably PHP based also possible to save setting in a database table or flat file.

  2. #2

    Join Date
    Jan 2008
    Posts
    111
    Thank Post
    6
    Thanked 19 Times in 15 Posts
    Rep Power
    17
    I'm no expert, but I can't see how this is possible without a cookie. There has to be some way of the user being recognised in order to select their preferred style, so that (as far as I know) means a cookie or them entering a username (which would of course defeat the object of the exercise!).

    You could use their IP address, but they change...

    Anyone know better?

    Simon

  3. #3

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    30
    Its basically a website where an Administrator will set the Theme for the whole school, this admin will not have access to the web server where the site and styles are kept so i need some dynamic way of the admin being able to do this.

    This is the reason why a cookie would not do it, it doesnt need to be user specific it needs to be site specific.

  4. #4
    kesomir's Avatar
    Join Date
    Mar 2008
    Location
    London
    Posts
    288
    Thank Post
    15
    Thanked 28 Times in 23 Posts
    Rep Power
    18
    in the header of the file (named something.php) where the css would go (between <style> and </style>):

    (done in php)

    Code:
    <?php
    $config_theme = '/home/user/www/mysite/config_folder/config.cfg';
    
    //check config file exists
    if(file_exists ($config_theme)){
    
    //open file, read the contents to variable
    $theme = file_get_contents ($config_theme);
    include '/path/to/css/folder/'.$theme;
    }
    else{
    //include default
    include './path/to/default.css';
    }
    
    ?>
    if you need to allow them to switch based on a web form, you need to create a form with a dropdown with the themes in, then process the data received to write the contents of the file referenced above.

    If you don't need them to do that via web and they can access the file direct, you can set the variable in the config file and just include it before pulling the css file.

    EDIT: let me know if you need help with the form parts.
    Last edited by kesomir; 22nd August 2008 at 07:38 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. template switcher
    By alonebfg in forum EduGeek Joomla 1.5 Package
    Replies: 0
    Last Post: 12th May 2008, 11:29 PM
  2. KompoZer - style sheet
    By speckytecky in forum Web Development
    Replies: 0
    Last Post: 22nd April 2008, 09:39 PM
  3. Get married in style
    By StewartKnight in forum General Chat
    Replies: 7
    Last Post: 4th March 2008, 11:05 AM
  4. Colour Switcher problem
    By carolla in forum Web Development
    Replies: 15
    Last Post: 9th August 2007, 09:19 AM
  5. Kiosk-style XP PC?
    By tarquel in forum Windows
    Replies: 15
    Last Post: 24th June 2005, 10:38 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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