Justice-Inc
Nov 25 2004, 03:47 AM
This script uses a cookie, so that's your only real restriction, as some browsers wont accept them usually due to privacy/security settings, but most will.
--------------------------------------------------------------------------------
Firstly you'll want to create the themes/styles that you want to use, the more knowledge you have of css the better as your styles need to be mostly css based.
Lets say you have two styles style1.css and style2.css now we'll create the file that does the switching between the two.
CODE
Code:
<?php
if (isset($_POST['set'])) {
//set a cookie with the users choice of theme
setcookie ('theme',$_POST['set'],time()+31536000,'/','.domain.com','0');
//send the user back to the same page
header("Location: $HTTP_REFERER");
}
else {
header("Location: $HTTP_REFERER");
}
?>
Hopefully you can see what to edit "domain.com" is obviously the most important, the rest you can leave as is, 31536000 is the time the cookie you set will last for (in seconds) this is a year, you can edit that if you like.
That's basically all the code you need, save it as theme.php and upload, next we need to include the chosen css file into our page.
CODE Code:
<link rel="stylesheet" type="text/css" title="user theme" href="http://domain.com/<? echo(!$theme)?'style':$theme ?>.css">
Again you need to edit "domain.com" and this should be the full path to your css files, so if they are in a folder called "themes" you would have href="http://domain.com/themes/ etc (don't forget the trailing slash) this will include the chosen theme that's been defined from theme.php
Ideally this should be in the <head> section of your page, and obviously in all pages that you want to apply the style to.
Only one thing left to do, and that's give your users a way to change the theme, basically all you really need to do is call the following url http://yourdomain.com/theme.php?set=css_file_name (make sure you leave the .css off the end of the css file name)
The easiest way for people to select a style would be via a drop down box, something like the following:
CODE Code:
<form name="theme" action="theme.php" method="post">
<select name="set" onChange="this.form.submit()">
<option value="">-- select --</option>
<option value="style1">Style1</option>
<option value="style2">Style2</option>
</select>
</form>
That's all you need, as the user selects a theme from the list it'll set the $set variable as either style1 or style2, set the cookie with the selected style and call the relevant .css file
Reply
Similar Topics
Keywords : php css style switcher- Personality Test - With Signing Style
- (8)
QUOTE SINGLE UNDERLINE BELOW THE SIGN These persons are very confident and are good
personalities. They are a little bit selfish but believe in "Happiness of human life". TWO DOTS
BELOW THE SIGN These persons are considered to be Romantic, can easily change their fiancees as if
they change their clothes. They prefer beauty in other persons & they themselves try to look
beautiful. They easily attract others. SINGLE DOT BELOW THE SIGN These persons are more inclined
towards classical arts, simple & are very cool. If you loose faith with them, then these perso...
Celebrating S & M Style
- (9)
Poll: What's Your Eating Style?
- Alone, semi-alone, or in a group? (21)
I wonder what a person's eating style says about him or her. For example, someone who likes to
be semi-alone may be shy, quiet, or just plain stuck-up. Or may be she likes to observe others'
eating behavior...For me I like eating totally alone because it makes me less sleepy afterward and
gives me time to mull. What about you?...
Mcdonald's Beefs Up Menu For Tech-savvy
- ATM-style device called the Blaze Net (15)
QUOTE Burning CDs, downloading mobile-phone ringtones, even printing digital-quality photos
could soon be the newest things on the McDonald's menu.
http://seattletimes.nwsource.com/html/busi...wiredmcd30.html aherm... what do you think? can this
be the future of mcdonalds? /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif'
/> and will you be compelled to stay at mcdonalds longer? (though i would suppose most of you stay
long at mcdonalds already /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif'
/> ). if you'...
Php Forum Style Management
- How do i install a style? (8)
Ok I want to know, in a very detailed manner, how to install a DL'ed theme or style into my php
forums. I have filezilla but i dont know how to use it. Please try to give a thorough walkthrough
cuz im new at this. Any help is desperately needed cuz my forums are all jacked up. Thank you ~Lord
of the Sabbath...
phpBB RPG style
- (13)
I need some "medieval" skin for my forum (i already have chronicle) the pics doesn't have to be
"medieval" i can arrange that, i just want that the skins has some nice medieval color, like dark
brown... something medieval what :roll:
Exemple: Nice brown skin anyone has saw a template
with those colors? Thanks /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> ...
PhpBB Style Help??
- (5)
How do I create a new style in phpbb? like for the whole page to change?...
A New Grunge/whatever Style im going for.
- (9)
Rating ?...
cascading style sheets
- (20)
G'day what is the best program to use to create css and what is the real benifit of using them. :?...
I'm writing a Film Noir style script
- (17)
Kinda like *BLEEP* Tracy or The Shadow . You know what I mean?
So the villian is Tony Kohuda.
He does all the usual stuff like tables, slots numbers.
And the rest is basically
fill-in-the-blanks.
Whats the main characters name?? Whats the girls name? (Every story needs a
dame)
And most important what is about??
Did I mention I am at the start of writing this?
____
edit:
The villians name is probably not Tony Kouhuda any more. Read on......
The Mullet
- wtf is up with this hair style (8)
TheMullet has to be the dumbestlooking hair i have ever seen, lol it wis widelymade fun of
everywhere. there is a book u can buy at barnes and noble, calledthe arrow dynamics of the mullet,
and this book it soo funny, it show hicks with funnylooking mullets ( almost look like joe dirt ) i
just cant stand the way this hair stylelooks, lol.. sorry if i offended anyone here, i meant none
||::._ Attention Trap17.com Forum Members _::|| It Will be Appreciated if you see something that
interests you in the google ads, to click them once a day, everytime the page views refre...
Looking for php, css, style, switcher
|
|
Searching Video's for php, css, style, switcher
|
advertisement
|
|