danIT Posted August 22, 2008 Posted August 22, 2008 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.
NotSoFast Posted August 22, 2008 Posted August 22, 2008 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
danIT Posted August 22, 2008 Author Posted August 22, 2008 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.
kesomir Posted August 22, 2008 Posted August 22, 2008 (edited) in the header of the file (named something.php) where the css would go (between ): (done in 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. Edited August 22, 2008 by kesomir
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now