Click to See Complete Forum and Search --> : style


chris9902
08-04-2003, 03:37 PM
i think this is a CSS question

i want people to be able to load different styles for my site.

if i make 5 .css files and have 5 buttons on my site can it change the style sheet according to the button they press.

can you control images in .css files? if so HOW?


thanks alot

David Harrison
08-04-2003, 03:55 PM
You would have to have 5 different pages for the 5 different styles.
To use CSS to control ALL images you can do something like this:

<style type="text/css"><!--

img{width:100px;height:100px;}

--></style>

pyro
08-04-2003, 04:14 PM
To change the styles, you will need to use either javascript or a serverside language. The latter is MUCH better, as it will work for those without javascript enabled (13%). On http://www.webdevfaqs.com we did this useing PHP to set a cookie with their preferences set.

chris9902
08-04-2003, 04:27 PM
ok thanks

pyro
08-04-2003, 04:33 PM
You bet... ;)

nkaisare
08-04-2003, 05:17 PM
Originally posted by pyro
To change the styles, you will need to use either javascript or a serverside language. The latter is MUCH better, as it will work for those without javascript enabled (13%). On http://www.webdevfaqs.com we did this useing PHP to set a cookie with their preferences set.
I believe thats OK as long as javascript is just for changing the look of the site... something superficial. It should not be used for some key element of site (such as navigation)

pyro
08-04-2003, 05:22 PM
Yes, but my philosophy on it would be why use javascript for things that can be done serverside? I can see no benefit to using javascript over PHP (or any other apporopriate serverside language). But, I agree, if the site still continues to function, it's not a big deal if users with javascript disabled are not able to change the stylesheets used to present the page.

chris9902
08-04-2003, 05:27 PM
so can someone help or point me in the right direction on how to do this.:)

pyro
08-04-2003, 05:36 PM
With PHP, it would go like this:

Set up your links to change the styles something like this:

<a href="changecss.php?file=default>default style</a>
<a href="changecss.php?file=stylesheetname>change style</a>

Where changecss.php looks like this:

<?PHP
$loc = $_SERVER["HTTP_REFERER"];
$css = $_GET["file"];

setcookie("stylesheets",$css,time()+31536000); #one year
header ("Location:$loc");
?>Then, on each page, include this bit of PHP where the stylesheets should be displayed (<head>):

<?PHP
if(isset($_COOKIE["stylesheets"])) {
$val = $_COOKIE["stylesheets"];
if ($val == "stylesheetname") {
echo "<link rel=\"stylesheet\" href=\"stylesheetname.css\" type=\"text/css\">";
}
else {
echo "<link rel=\"stylesheet\" href=\"default.css\" type=\"text/css\">";
}
}
else {
echo "<link rel=\"stylesheet\" href=\"default.css\" type=\"text/css\">";

}
?>

chris9902
08-04-2003, 06:32 PM
ok thanks.

i will try it out later when i wake up and get back 2 you

but it looks good

chris9902
08-04-2003, 06:43 PM
for some f***ing reason my server will not let me upload

can anyone tell me how i can test PHP on my local server (my computer)

as simple as possible, i don't no **** about PHP

Da Warriah
08-04-2003, 06:58 PM
well to set PHP up on my computer i used this tutorial:

http://robouk.mchost.com/tuts/tutorial.php?tutorial=server1

i found it very easy to follow, just skip the MySQL part if you arent interested in that;)

chris9902
08-04-2003, 07:28 PM
lol:eek:

i am using the EXACT same tutorial

just none of the links to the setup files work, i can't download;

Apache 1.3.5
Mysql 3.23.49
or
PHP 4.2.0

Da Warriah
08-04-2003, 08:43 PM
lol yeah some of the links are a bit outdated, you have to search around a bit...but after that its fine...

http://www.apache.org/dist/httpd/binaries/win32/old/apache_1.3.24-win32-x86-no_src.exe

http://www.mysql.com/downloads/download.php?file=Downloads/MySQL-3.23/mysql-3.23.49-win.zip&pick=mirror - it seems to be there, try downloading it from a mirror down below...

http://ca3.php.net/get/php-4.3.2-installer.exe/from/a/mirror - theres 4.3.2, its stable, and its what i downloaded...its workin fine;)

chris9902
08-05-2003, 07:18 AM
thats great.

so now i can test PHP on my local server

chris9902
08-05-2003, 10:05 AM
can you help me set up the Mysql part i can't do it i just get error messages.

aslo the script you posted what parts do i change?

thanks alot

Robert Wellock
08-07-2003, 08:43 AM
If you aren't familiar with Apache you could have downloaded phpdev: http://www.firepages.com.au/dev4.htm to make life easier.