[SOLVED] Changing Colours

This is a discussion on "[SOLVED] Changing Colours" within the PHP Forum section. This forum, and the thread "[SOLVED] Changing Colours are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 18th, 2007, 13:24
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
[SOLVED] Changing Colours

Sorry if this is in the wrong area, but here goes with my Q!?

On my portfolio website, I have a certain colour scheme, but when doing making it, i went through loads of different colour schemes, and most were liked, so what I was wondering was, whats the code, so that someone can just pick the colour scheme they like and use it for the rest of the site!
I dont no where to begin

Thanks for any help
Cracka
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 18th, 2007, 13:31
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

I would just set up a .css file for each colour scheme and then use a script that stores the prefered scheme in either $_GET, $_SESSION or $_COOKIE to write the required file to the page.

If you have a database backend you could do the same thing with a DB query.

I wrote a similar snippet for swagner in http://www.webforumz.com/php-forum/6...endly-page.htm

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 18th, 2007, 13:46
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

Hi, thanks for your help, but I am complete beginner at php you see, so don't really have a clue what is being said in that link you sent me, sorry for being such a dumb***, could you try walk me through it a bit more please!

Thanks
Cracka
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 19th, 2007, 13:46
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

Can Anyone Help Me With This?
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 19th, 2007, 13:56
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

do you have any code already?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 19th, 2007, 14:15
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

No, complete beginner, I know nothing really about php!
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 19th, 2007, 14:43
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

HTML code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 19th, 2007, 15:20
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

http://www.alistapart.com/stories/alternate/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 19th, 2007, 21:45
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

Okay, say you have 4 styles of css you can use the below code.. Just replace your current <link etc.. with the PHP below, then add a form or link on your site that sends style=(1,2,3 or 4) to your pages.

PHP: Select all

<?php


$myStyles 
= array ();

$myStyles[1] = 'this.css';
$myStyles[2] = 'that.css';
$myStyles[3] = 'your.css';
$myStyles[4] = 'mine.css';

// This will add selected style to the session
if (isset($_REQUEST['style']) && isset($myStyles[$_REQUEST['style']]))
    
$_SESSION['style'] = $myStyles[$_REQUEST['style']];

// now write to the page

if (in_array($_SESSION['style'], $myStyles))
    echo 
'<link href="'$_SESSION['style'], '" rel="stylesheet" type="text/css" />';
else
    echo 
'<link href="'$myStyles[1], '" rel="stylesheet" type="text/css />';

?>
So all you need to do is make it so when a user wants a different style, they are sent to the same page but add to the query string..

eg.

http://www.example.com/index.php?style=1

and for the rest of that session they will have that style.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Oct 22nd, 2007, 10:13
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

Hi Rakuli!
I have tried what you have suggested but it is still not working :S, and the link you sent me doesn't work, so that doesn't help me!
Do i have to use .php extension, or can i stick with the html?

Thanks
Cracka
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Oct 22nd, 2007, 10:19
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

Hi Cracka, the link is example.com and is used to actually show examples You would replace example.com with your domain once you have the php code in the files.

You need to have .php extensions for this to work, .html will not work unless without some apache tricks.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Oct 22nd, 2007, 10:21
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

Ok, thanks, my bad :P
Well i will have a look see if that does anything, and i will get back to you!

Thanks
Cracka
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Oct 22nd, 2007, 10:27
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

No, it is still not working
Here is a screenshot of what my webpage looks like using that code, hoping that would help!

Thanks
Cracka
Attached Images
File Type: jpg screenshot.jpg (298.0 KB, 3 views)
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 22nd, 2007, 10:47
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

LOL can't say that helps at all.

Can you post the code in the way you have integrated it?

say 10 lines before and after the PHP so see how you have dropped it in..

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Oct 22nd, 2007, 10:51
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 453
Thanks: 1
Thanked 4 Times in 4 Posts
Re: Changing Colours

Here is the code!:

PHP: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>CF DesigNz</title>

<?php
$myStyles 
= array ();
$myStyles[1] = 'styles.css';
$myStyles[2] = 'styles1.css';
$myStyles[3] = 'styles2.css';
$myStyles[4] = 'styles3.css';
// This will add selected style to the session
if (isset($_REQUEST['style']) && isset($myStyles[$_REQUEST['style']]))
    
$_SESSION['style'] = $myStyles[$_REQUEST['style']];
// now write to the page
if (in_array($_SESSION['style'], $myStyles))
    echo 
'<link href="'$_SESSION['style'], '" rel="stylesheet" type="text/css" />';
else
    echo 
'<link href="'$myStyles[1], '" rel="stylesheet" type="text/css />';
?>
</head>
<body>
<div id="header"><img src="images/header.jpg" alt=""></div>
<div id="menu"><img src="images/menu.jpg" alt=""></div>
<div id="menucont"><a href="index.htm">Home</a> | <a href="services.htm">Services</a> | <a href="portfolio.htm">Portfolio</a> | <a href="contact.asp">Contact Me</a> |<a href=""> Blog</a></div>
<div id="main"><img src="images/main.jpg" height="630" width="999" alt=""></div>
<div id="maintext"><h1>CF DesigNz</h1>I am a website Designer and Developer. I can create websites from scratch or modify a template produced in Graphical programs such as Photoshop and Fireworks.  I can create websites in different langauges such as:
Thanks
Cracka
__________________
Check out my Portfolio cfdesignz.co.uk and my blog at blog.cfdesignz.co.uk
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Oct 22nd, 2007, 10:56
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

PHP: Select all



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>CF DesigNz</title>



<?php

$myStyles 
= array ();

$myStyles[1] = 'styles.css';

$myStyles[2] = 'styles1.css';

$myStyles[3] = 'styles2.css';

$myStyles[4] = 'styles3.css';

// This will add selected style to the session

if (isset($_GET['style']) && isset($myStyles[$_GET['style']]))

    
$_SESSION['style'] = $myStyles[$_GET['style']];

// now write to the page

if (in_array($_SESSION['style'], $myStyles))

    echo 
'<link href="'$_SESSION['style'], '" rel="stylesheet" type="text/css" />';

else

    echo 
'<link href="'$myStyles[1], '" rel="stylesheet" type="text/css />';

?>

</head>

<body>

<div id="header"><img src="http://www.webforumz.com/images/header.jpg" alt=""></div>

<div id="menu"><img src="http://www.webforumz.com/images/menu.jpg" alt=""></div>

<div id="menucont"><a href="index.htm">Home</a> | <a href="services.htm">Services</a> | <a href="portfolio.htm">Portfolio</a> | <a href="contact.asp">Contact Me</a> |<a href=""> Blog</a></div>

<div id="main"><img src="http://www.webforumz.com/images/main.jpg" height="630" width="999" alt=""></div>

<div id="maintext"><h1>CF DesigNz</h1>I am a website Designer and Developer. I can create websites from scratch or modify a template produced in Graphical programs such as Photoshop and Fireworks.  I can create websites in different langauges such as:
Try that:

To ask a couple of obvious questions, you're going to yoursite/index.php?style=1/2/3 or 4 and you have your stylesheets in the same directory as the page?
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!