[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.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2007, 13:24
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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
Reply With Quote

  #2 (permalink)  
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 [SOLVED] PHP Printer-Friendly Page

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 18th, 2007, 13:46
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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
Reply With Quote
  #4 (permalink)  
Old Oct 19th, 2007, 13:46
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

Can Anyone Help Me With This?
Reply With Quote
  #5 (permalink)  
Old Oct 19th, 2007, 13:56
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Changing Colours

do you have any code already?
Reply With Quote
  #6 (permalink)  
Old Oct 19th, 2007, 14:15
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

No, complete beginner, I know nothing really about php!
Reply With Quote
  #7 (permalink)  
Old Oct 19th, 2007, 14:43
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Changing Colours

HTML code?
Reply With Quote
  #8 (permalink)  
Old Oct 19th, 2007, 15:20
SuperMember

SuperMember
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/
Reply With Quote
  #9 (permalink)  
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)
Reply With Quote
  #10 (permalink)  
Old Oct 22nd, 2007, 10:13
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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
Reply With Quote
  #11 (permalink)  
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)
Reply With Quote
  #12 (permalink)  
Old Oct 22nd, 2007, 10:21
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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
Reply With Quote
  #13 (permalink)  
Old Oct 22nd, 2007, 10:27
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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)
Reply With Quote
  #14 (permalink)  
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)
Reply With Quote
  #15 (permalink)  
Old Oct 22nd, 2007, 10:51
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 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
Reply With Quote
  #16 (permalink)  
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)
Reply With Quote
  #17 (permalink)  
Old Oct 22nd, 2007, 12:19
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

No that didn't work, the top images didn't work, because it was set to webforumz , how come you did that?

So it is still not working!
&& Yess, my stylesheets are in the same directory as the index file, any other suggestions?

Thanks
Cracka
Reply With Quote
  #18 (permalink)  
Old Oct 22nd, 2007, 12:36
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 have no idea how that happened I honestly did not add webforumz to the urls.. When I first posted all spaces were replaces with asterixes too... very weird..

Have you viewed the source to see if a different link is being written each time? Can you also check your PHP error log.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #19 (permalink)  
Old Oct 22nd, 2007, 12:40
crackafaza's Avatar
Resources Team
Join Date: Jun 2007
Location: UK
Posts: 421
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing Colours

Hi!
There is no error coming onto the page, its just rearrangeing the text and images funny, so i am still confused, would it be easier for me to send the zip file to you, and you have a play around with it?

Thanks
Cracka
Reply With Quote
  #20 (permalink)  
Old Oct 22nd, 2007, 12:43
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

Yeah do that
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Changing onfocus of a textbox djeyewater JavaScript Forum 5 Jan 5th, 2008 17:38
[SOLVED] CSS changing page colour etc R8515198 Web Page Design 10 Nov 27th, 2007 00:54
[SOLVED] changing links colours using html R8515198 Web Page Design 32 Nov 12th, 2007 08:19
[SOLVED] Changing from html to CSS mcdanielnc89 Web Page Design 16 Oct 11th, 2007 04:29
[SOLVED] Changing pictures on same page R8515198 JavaScript Forum 7 Oct 3rd, 2007 00:14


All times are GMT. The time now is 22:26.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8