Page 1 of 1

need help getting started parsing css data

Posted: Wed Sep 18, 2002 10:02 am
by lanlord
I just finished coding a PHP based helpdesk app, and I find out one of the users is color blind. I figure, no prob, I'll just give him a way to set his own preferences. Of course, I'm using CSS.

Giving the user a form with choices and writing it all out to a css file is no problem, but what I want to do is first read in an existing css doc, which is formatted like this:

BODY {
border: 2;
background: #dddddd;
font: verdana, Arial, Helvetica;
font-size: 8pt;
color: black;
}
A:LINK {
font-family: verdana, Arial, Helvetica;
font-size: 8pt;
color: darkblue;
text-decoration: none;
}
...


By reading it in, the user never has to completely start over.

Is the best way to handle this with arrays, evaluating each element as the page is rendered? For instance:

$style["body"]["border"] = "2";
$style["body"]["background"] = "#dddddd";
...

or is there a more elegant, more sensible way of doing this?

Posted: Wed Sep 18, 2002 3:50 pm
by Takuma
Couldn't you use Templates? Try "EasyTemplate".

Posted: Thu Sep 19, 2002 7:41 pm
by lanlord
Thanks, I'll look into it. Since I don't know what that is, I hope I can find it on Google!

I think

Posted: Thu Sep 19, 2002 10:04 pm
by AVATAr
I think your idea of using css is ok... you can use XML if you want to.. but using an array so the user could avoid starting over is a good and simpler idea.

Templates are a different thing...

Posted: Thu Sep 19, 2002 10:09 pm
by hob_goblin
templates are irrelevant...

your way seems nice, that's probably how I would do it. If the user knew css, I would probably just read it into a textarea and let them directly edit it.. but assuming they don't, your way seems the best.

I need to protect my poor users from the code

Posted: Fri Sep 20, 2002 1:58 pm
by lanlord
I have decided to do this using arrays. If anyone wants what I come up with, send me your email and I'll send you the finished code.