Jump to content


select your color theme?


14 replies to this topic

#1 tyler

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 21 September 2005 - 07:04 AM

Im redesigning my website and i'm looking to have an option on the index page where you can choose the color theme.

How would i go about doing this?

#2 tyler

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 21 September 2005 - 07:11 AM

meant to say that the color theme will be images

#3 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 21 September 2005 - 01:38 PM

Ok first off name all your images regarding color. So
red_bar.jpg or blue_bar.jpg ect.

Then make a form with a select option with all the colors.
Make the name of your select color.

Then include this code:
if (isset($_GET['color'])){
$color = $_GET['color'];
}else{
if isset($_POST['color']){
$color = $_POST['color'];
}else{
$color = 'DEFAULTCOLORHERE';
}
}
echo '<img src="'.$color.'.jpg">';

Make sure everythign link has ?color='.$color.' at the end of your links so the color is carried over.

Edited by Lang, 21 September 2005 - 01:40 PM.


#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 September 2005 - 03:23 PM

Or you could simply search through one of the 5,000 tutorials on how to do this in CSS
The database should have a few, and i believe spoono.com has a tutorial on how they do theirs.

But if you're doing actual images like what lang mentioned, you can try that, or javascript (javascript would probably be harder)

#5 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 21 September 2005 - 10:39 PM

Just use the code off of spoonos page.

www.spoono.com

They wont mind.

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 22 September 2005 - 03:20 PM

You're right they won't mind, that's only copyright violation... Nothing wrong with that...
You can look at their code to see what they did, but don't copy/paste and change a few image names

p.s. My first statement is sarcasim, copyright violation is illegal...

#7 blinek

    Jedi In Training

  • Members
  • PipPip
  • 377 posts
  • Location:Earth

Posted 23 September 2005 - 02:54 PM

Lang

could you please elaborate more

~aeiko

#8 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 23 September 2005 - 06:34 PM

rc69, on Sep 22 2005, 08:20 PM, said:

You're right they won't mind, that's only copyright violation... Nothing wrong with that...
You can look at their code to see what they did, but don't copy/paste and change a few image names

p.s. My first statement is sarcasim, copyright violation is illegal...
Haha no they dont care, its in there tutorials somewere.

Ive asked on the forums aswell.

#9 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 23 September 2005 - 08:49 PM

why not just use sessions?

#10 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 24 September 2005 - 02:10 AM

using sessions would have a problem, because if u did the nav wrong it would cause errors... cookies might work though

#11 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 24 September 2005 - 11:14 AM

sessions would work fine actually imo.. cookies would be beqtter but you'd need to have more experience in php

#12 austen

    P2L Jedi

  • Members
  • PipPipPip
  • 910 posts
  • Location:Montana, US
  • Interests:Web design, snowboarding (lots of it), Computer science related.

Posted 24 September 2005 - 11:20 AM

I'd say that PHP Cookies would probably be one of the best ways to get this done, look for php theme changer tutorials or something of the like. I'm pretty sure that I've read somewhere on spoono that this the method they use. In my opinion it would be the best way at least for a layout with images. Cookies aren't really that much harder than sessions either, if you'd like more help with how to do this, I can give you a basic example, just pm me.

#13 austen

    P2L Jedi

  • Members
  • PipPipPip
  • 910 posts
  • Location:Montana, US
  • Interests:Web design, snowboarding (lots of it), Computer science related.

Posted 24 September 2005 - 11:21 AM

MillerTime, on Sep 24 2005, 04:14 PM, said:

sessions would work fine actually imo.. cookies would be beqtter but you'd need to have more experience in php
though also using a session would eventually expire and if they wanted it to stay the same color each time they got on cookies would be the best way.

#14 tyler

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 24 September 2005 - 08:32 PM

cheers for all the help guys, i will give this ago and let you know how i get on <_<

thanks again :ph34r:

#15 Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 24 September 2005 - 09:56 PM

tyler, on Sep 25 2005, 01:32 AM, said:

cheers for all the help guys, i will give this ago and let you know how i get on :D

thanks again :D
Hey, if you havnt figured it out yet, I already had a script somewhere on the forums in another help post about it! ;)

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

As you may of seen on http://www.spoono.com They have a skin changer! This is something similar and it has the same idea as theirs. Just that this has a refresh page that will bring you back to the last page page you were viewing instead of going back to the home page.

1) First off, create your index.php This will have a very few lines of code, and add this in there:

Quote

//COOKIE MONSTER
ini_set("session.cookie_lifetime", "315360000");
session_start();

//Settign the styles
switch($_SESSION["style"])
{
case "red":
  include("red.php");
  break;
/*
To add a new skin, simply add:
case "NAME OF SKIN":
  include("FILENAME TO SKIN");
  break;
*/
default:
  include("default.php");
  break;
}
?>

All your skins will be in different files. Your default skin will be set to default.php So you would set up that file the same you would with index.php. If you wanted a red skin. You could simply create the red skin on the file red.php with the images set to the red images and etc. Please also note:

Quote

/*
To add a new skin, simply add:
case "NAME OF SKIN":
  include("FILENAME TO SKIN");
  break;
*/

2) Now, create a style.php and insert this code:

Quote

//COOKIE MONSTER
ini_set("session.cookie_lifetime", "315360000");
session_start();
$_SESSION["style"] = $_GET["set"];
?>

Please Wait...
 

 

  layout scheme selected, please wait to be redirected...
 

 

( Click here if you are not redirected in 3 seconds )


Please notice the code $HTTP_REFERER which is the last page you visited. If you did not visit a page before the style page is loaded. You are stuck <_<

To change a skin, you can simply set a hyperlink to

Quote

style.php?set=red
and it will redirect you to the index.php but this time, it is loading from the red theme.

Final Notes: Cookies must be enabled for this to work. Also, this is a lifetime cookie so it will take a LONG time to expire.

If you have any questions, comments, suggestions, please feel free to speak your mind.

Tutorial Copyright © 2005 Chaos King -- Pixel-Designz

Hoped this helped you if you still needed it. :ph34r:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users