need help getting started parsing css data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
lanlord
Forum Newbie
Posts: 13
Joined: Wed Sep 18, 2002 10:02 am

need help getting started parsing css data

Post 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?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Couldn't you use Templates? Try "EasyTemplate".
User avatar
lanlord
Forum Newbie
Posts: 13
Joined: Wed Sep 18, 2002 10:02 am

Post by lanlord »

Thanks, I'll look into it. Since I don't know what that is, I hope I can find it on Google!
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

I think

Post 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...
Last edited by AVATAr on Thu Sep 19, 2002 10:11 pm, edited 1 time in total.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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.
User avatar
lanlord
Forum Newbie
Posts: 13
Joined: Wed Sep 18, 2002 10:02 am

I need to protect my poor users from the code

Post 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.
Post Reply