Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #4486 > unrolled thread

Parsing .css files with php: Cons?

Started by"J. Frank Parnell" <juglesh@gmail.com>
First post2012-01-16 13:36 -0800
Last post2012-01-23 23:44 +0100
Articles 20 on this page of 24 — 10 participants

Back to article view | Back to comp.lang.php


Contents

  Parsing .css files with php: Cons? "J. Frank Parnell" <juglesh@gmail.com> - 2012-01-16 13:36 -0800
    Re: Parsing .css files with php: Cons? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-01-17 11:42 +0100
    Re: Parsing .css files with php: Cons? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-01-17 13:31 +0100
    Re: Parsing .css files with php: Cons? Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-17 04:32 -0800
      Re: Parsing .css files with php: Cons? "J. Frank Parnell" <juglesh@gmail.com> - 2012-01-19 12:45 -0800
        Re: Parsing .css files with php: Cons? Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-20 02:07 -0800
          Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-20 11:25 +0100
            Re: Parsing .css files with php: Cons? Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-20 05:33 -0800
              Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-20 15:05 +0100
                Re: Parsing .css files with php: Cons? Chuck Anderson <cycletourist@invalid.invalid> - 2012-01-20 18:50 -0700
                  Re: Parsing .css files with php: Cons? "J.O. Aho" <user@example.net> - 2012-01-21 08:10 +0100
                    Re: Parsing .css files with php: Cons? Chuck Anderson <cycletourist@invalid.invalid> - 2012-01-21 12:31 -0700
                      Re: Parsing .css files with php: Cons? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-21 15:53 -0500
                        Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-21 22:22 +0100
                          Re: Parsing .css files with php: Cons? "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2012-01-21 21:37 +0000
                            Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-22 22:35 +0100
                              Re: Parsing .css files with php: Cons? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-22 19:19 -0500
                          Re: Parsing .css files with php: Cons? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-21 17:08 -0500
                            Re: Parsing .css files with php: Cons? Chuck Anderson <cycletourist@invalid.invalid> - 2012-01-21 18:17 -0700
                              Re: Parsing .css files with php: Cons? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-21 23:14 -0500
                            Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-22 22:35 +0100
                              Re: Parsing .css files with php: Cons? "Peter H. Coffin" <hellsop@ninehells.com> - 2012-01-22 17:14 -0600
                                Re: Parsing .css files with php: Cons? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-22 19:21 -0500
                                Re: Parsing .css files with php: Cons? Michael Fesser <netizen@gmx.de> - 2012-01-23 23:44 +0100

Page 1 of 2  [1] 2  Next page →


#4486 — Parsing .css files with php: Cons?

From"J. Frank Parnell" <juglesh@gmail.com>
Date2012-01-16 13:36 -0800
SubjectParsing .css files with php: Cons?
Message-ID<400f69e3-9555-4cc0-b529-6dbca54d9bfa@k3g2000pbn.googlegroups.com>
given: I know about @import and cascading styles, etc etc.

Is is cool to parse .css files with php?  Like I may want to include()
sections into an overall .css.  Or i may want to do like color:#<?php
echo $thecolor; ?>.  That kind of stuff.

I guess there might be a little more overhead, but what's a few .css
files within a whole cms like wordpress?  I'm just looking for gotchas
and unforseen problems.

thanks,
j

[toc] | [next] | [standalone]


#4493

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2012-01-17 11:42 +0100
Message-ID<4f15509c$0$6919$e4fe514c@news2.news.xs4all.nl>
In reply to#4486
On 1/16/2012 10:36 PM, J. Frank Parnell wrote:
> given: I know about @import and cascading styles, etc etc.
>
> Is is cool to parse .css files with php?  Like I may want to include()
> sections into an overall .css.  Or i may want to do like color:#<?php
> echo $thecolor; ?>.  That kind of stuff.
>
> I guess there might be a little more overhead, but what's a few .css
> files within a whole cms like wordpress?  I'm just looking for gotchas
> and unforseen problems.
>
> thanks,
> j

Hi,

It is possible, but I prefer making multiple stylesheets.
Make the included stylesheet conditional.
eg:

<?php
  $usedstylesheet = ($test?"mycss/ver_abc.css":"mycss/ver_123.css");
$>
<link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
href="http://www.example.com/<?php echo $usedstylesheet; ?>">

That way you have no PHP defining your stylesheet. That will make 
webdesigners who have to modify it later happy. ;-)

Regards,
Erwin Moller


-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#4494

From"Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid>
Date2012-01-17 13:31 +0100
Message-ID<jf3plp$9da$1@dont-email.me>
In reply to#4486
El 16/01/2012 22:36, J. Frank Parnell escribió/wrote:
> given: I know about @import and cascading styles, etc etc.
>
> Is is cool to parse .css files with php?  Like I may want to include()
> sections into an overall .css.  Or i may want to do like color:#<?php
> echo $thecolor; ?>.  That kind of stuff.
>
> I guess there might be a little more overhead, but what's a few .css
> files within a whole cms like wordpress?  I'm just looking for gotchas
> and unforseen problems.

You might be interested in one of the existing CSS preprocessors, such 
as SASS or LESS. It's basically the idea you are describing, except that:

- CSS is generated once (not for every request).
- The code is already written (and not necessarily in PHP).


-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

[toc] | [prev] | [next] | [standalone]


#4495

FromCaptain Paralytic <paul_lautman@yahoo.com>
Date2012-01-17 04:32 -0800
Message-ID<a24408e9-1d0e-4fda-b38a-c9b63fab69fd@p4g2000vbt.googlegroups.com>
In reply to#4486
On Jan 16, 9:36 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
> given: I know about @import and cascading styles, etc etc.
>
> Is is cool to parse .css files with php?  Like I may want to include()
> sections into an overall .css.  Or i may want to do like color:#<?php
> echo $thecolor; ?>.  That kind of stuff.
>
> I guess there might be a little more overhead, but what's a few .css
> files within a whole cms like wordpress?  I'm just looking for gotchas
> and unforseen problems.
>
> thanks,
> j

I suspect a more normal way to do this would be to use php files to
generate your css rather like you would use them to generate your
html. So in the html sent to the browser you would have:
<link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
href="http://www.example.com/dynamic_css.php?anyparms">

and dynamic_css.php would return the css.

[toc] | [prev] | [next] | [standalone]


#4529

From"J. Frank Parnell" <juglesh@gmail.com>
Date2012-01-19 12:45 -0800
Message-ID<c60e98fb-abdf-495e-8df5-18cf66a303ec@v6g2000pba.googlegroups.com>
In reply to#4495
On Jan 17, 4:32 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jan 16, 9:36 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
>
> > given: I know about @import and cascading styles, etc etc.
>
> > Is is cool to parse .css files with php?  Like I may want to include()
> > sections into an overall .css.  Or i may want to do like color:#<?php
> > echo $thecolor; ?>.  That kind of stuff.
>
> > I guess there might be a little more overhead, but what's a few .css
> > files within a whole cms like wordpress?  I'm just looking for gotchas
> > and unforseen problems.
>
> > thanks,
> > j
>
> I suspect a more normal way to do this would be to use php files to
> generate your css rather like you would use them to generate your
> html. So in the html sent to the browser you would have:
> <link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
> href="http://www.example.com/dynamic_css.php?anyparms">
>
> and dynamic_css.php would return the css.

ok, yeah, this would be my preferred way of the three suggestions
(thanks all!).  Then, i suppose, I would need to set proper headers in
the php file?  or maybe it would come thru fine by itself?

[toc] | [prev] | [next] | [standalone]


#4535

FromCaptain Paralytic <paul_lautman@yahoo.com>
Date2012-01-20 02:07 -0800
Message-ID<e51383e9-cfa4-4f68-b5a1-36b024d4cd85@o9g2000yqa.googlegroups.com>
In reply to#4529
On Jan 19, 8:45 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
> On Jan 17, 4:32 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Jan 16, 9:36 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
>
> > > given: I know about @import and cascading styles, etc etc.
>
> > > Is is cool to parse .css files with php?  Like I may want to include()
> > > sections into an overall .css.  Or i may want to do like color:#<?php
> > > echo $thecolor; ?>.  That kind of stuff.
>
> > > I guess there might be a little more overhead, but what's a few .css
> > > files within a whole cms like wordpress?  I'm just looking for gotchas
> > > and unforseen problems.
>
> > > thanks,
> > > j
>
> > I suspect a more normal way to do this would be to use php files to
> > generate your css rather like you would use them to generate your
> > html. So in the html sent to the browser you would have:
> > <link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
> > href="http://www.example.com/dynamic_css.php?anyparms">
>
> > and dynamic_css.php would return the css.
>
> ok, yeah, this would be my preferred way of the three suggestions
> (thanks all!).  Then, i suppose, I would need to set proper headers in
> the php file?  or maybe it would come thru fine by itself?

The latter

[toc] | [prev] | [next] | [standalone]


#4536

FromMichael Fesser <netizen@gmx.de>
Date2012-01-20 11:25 +0100
Message-ID<83gih757lb1shbfamuk67juagcmftmiu0d@mfesser.de>
In reply to#4535
.oO(Captain Paralytic)

>On Jan 19, 8:45 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
>> On Jan 17, 4:32 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>> > I suspect a more normal way to do this would be to use php files to
>> > generate your css rather like you would use them to generate your
>> > html. So in the html sent to the browser you would have:
>> > <link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
>> > href="http://www.example.com/dynamic_css.php?anyparms">
>>
>> > and dynamic_css.php would return the css.
>>
>> ok, yeah, this would be my preferred way of the three suggestions
>> (thanks all!).  Then, i suppose, I would need to set proper headers in
>> the php file?  or maybe it would come thru fine by itself?
>
>The latter

No. You have to explicitly send the correct header or some browsers
might ignore the CSS. For example

header('Content-Type: text/css; charset=UTF-8')

Micha

-- 
http://mfesser.de/blickwinkel

[toc] | [prev] | [next] | [standalone]


#4545

FromCaptain Paralytic <paul_lautman@yahoo.com>
Date2012-01-20 05:33 -0800
Message-ID<65ce085f-7e7d-4ae3-af69-f96370944eac@m11g2000yqe.googlegroups.com>
In reply to#4536
On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Captain Paralytic)
>
> >On Jan 19, 8:45 pm, "J. Frank Parnell" <jugl...@gmail.com> wrote:
> >> On Jan 17, 4:32 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> >> > I suspect a more normal way to do this would be to use php files to
> >> > generate your css rather like you would use them to generate your
> >> > html. So in the html sent to the browser you would have:
> >> > <link type="text/css" rel="stylesheet" media="screen" charset="utf-8"
> >> > href="http://www.example.com/dynamic_css.php?anyparms">
>
> >> > and dynamic_css.php would return the css.
>
> >> ok, yeah, this would be my preferred way of the three suggestions
> >> (thanks all!).  Then, i suppose, I would need to set proper headers in
> >> the php file?  or maybe it would come thru fine by itself?
>
> >The latter
>
> No. You have to explicitly send the correct header or some browsers
> might ignore the CSS. For example
>
> header('Content-Type: text/css; charset=UTF-8')
>
> Micha
>
> --http://mfesser.de/blickwinkel

Oh OK. Any ideas which ones?

[toc] | [prev] | [next] | [standalone]


#4547

FromMichael Fesser <netizen@gmx.de>
Date2012-01-20 15:05 +0100
Message-ID<u0tih7dujcepc0r4td8jf4trspbvbdtnna@mfesser.de>
In reply to#4545
.oO(Captain Paralytic)

>On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
>> No. You have to explicitly send the correct header or some browsers
>> might ignore the CSS. For example
>>
>> header('Content-Type: text/css; charset=UTF-8')
>
>Oh OK. Any ideas which ones?

In the past Gecko browsers (i.e. Firefox) were a bit picky about the
correct CSS content type. If the file wasn't delivered as text/css, it
was ignored.

Micha

-- 
http://mfesser.de/blickwinkel

[toc] | [prev] | [next] | [standalone]


#4553

FromChuck Anderson <cycletourist@invalid.invalid>
Date2012-01-20 18:50 -0700
Message-ID<jfd5l1$cmc$1@dont-email.me>
In reply to#4547
Michael Fesser wrote:
> .oO(Captain Paralytic)
>
>   
>> On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
>>     
>>> No. You have to explicitly send the correct header or some browsers
>>> might ignore the CSS. For example
>>>
>>> header('Content-Type: text/css; charset=UTF-8')
>>>       
>> Oh OK. Any ideas which ones?
>>     
>
> In the past Gecko browsers (i.e. Firefox) were a bit picky about the
> correct CSS content type. If the file wasn't delivered as text/css, it
> was ignored.
>
> Micha

I have successfully used:
header("Content-type: text/css");

After implementing a php based style sheet a couple of different times 
it seemed wasteful, and a bit of a kludge. If the style sheet is 
ultimately static, it is wasteful to keep generating one every time it 
is used. Now I use a php script to generate the style sheet file for me. 
If I want to make changes I edit the php based file (or any included 
definition files, e.g., colors.php) and run it.

-- 
*****************************
 Chuck Anderson • Boulder, CO
  http://cycletourist.com
 Turn Off, Tune Out, Drop In
*****************************

[toc] | [prev] | [next] | [standalone]


#4554

From"J.O. Aho" <user@example.net>
Date2012-01-21 08:10 +0100
Message-ID<9nv6n4F6anU1@mid.individual.net>
In reply to#4553
Chuck Anderson wrote:
> Michael Fesser wrote:
>> .oO(Captain Paralytic)
>>
>>> On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
>>>> No. You have to explicitly send the correct header or some browsers
>>>> might ignore the CSS. For example
>>>>
>>>> header('Content-Type: text/css; charset=UTF-8')
>>> Oh OK. Any ideas which ones?
>>
>> In the past Gecko browsers (i.e. Firefox) were a bit picky about the
>> correct CSS content type. If the file wasn't delivered as text/css, it
>> was ignored.
>>
> I have successfully used:
> header("Content-type: text/css");
>
> After implementing a php based style sheet a couple of different times it
> seemed wasteful, and a bit of a kludge. If the style sheet is ultimately
> static, it is wasteful to keep generating one every time it is used. Now I use
> a php script to generate the style sheet file for me. If I want to make
> changes I edit the php based file (or any included definition files, e.g.,
> colors.php) and run it.
>

I have to say it feels quite much of extra work, writing the php script which 
generates the css, as you need to edit the php file, then IMHO you can quite 
easily edit a css instead. I could see a bit more point of your script if you 
have a database as a backend, where you store the values and recreate the css 
each time the values change.


-- 

   //Aho

[toc] | [prev] | [next] | [standalone]


#4556

FromChuck Anderson <cycletourist@invalid.invalid>
Date2012-01-21 12:31 -0700
Message-ID<jff3rm$das$1@dont-email.me>
In reply to#4554
J.O. Aho wrote:
> Chuck Anderson wrote:
>> Michael Fesser wrote:
>>> .oO(Captain Paralytic)
>>>
>>>> On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
>>>>> No. You have to explicitly send the correct header or some browsers
>>>>> might ignore the CSS. For example
>>>>>
>>>>> header('Content-Type: text/css; charset=UTF-8')
>>>> Oh OK. Any ideas which ones?
>>>
>>> In the past Gecko browsers (i.e. Firefox) were a bit picky about the
>>> correct CSS content type. If the file wasn't delivered as text/css, it
>>> was ignored.
>>>
>> I have successfully used:
>> header("Content-type: text/css");
>>
>> After implementing a php based style sheet a couple of different 
>> times it
>> seemed wasteful, and a bit of a kludge. If the style sheet is ultimately
>> static, it is wasteful to keep generating one every time it is used. 
>> Now I use
>> a php script to generate the style sheet file for me. If I want to make
>> changes I edit the php based file (or any included definition files, 
>> e.g.,
>> colors.php) and run it.
>>
>
> I have to say it feels quite much of extra work, writing the php 
> script which generates the css, as you need to edit the php file, then 
> IMHO you can quite easily edit a css instead. 

I edit one php file and then simply invoke it.  There is very little 
more "work."

In preparation, I write a script that opens a file for writing (the css 
file) and then one long heredoc to create it's contents.  This creates 
an easily reusable system for very little extra work.

> I could see a bit more point of your script if you have a database as 
> a backend, where you store the values and recreate the css each time 
> the values change.

It's not a database, but I include color definitions from a separate php 
file.

-- 
*****************************
 Chuck Anderson • Boulder, CO
  http://cycletourist.com
 Turn Off, Tune Out, Drop In
*****************************

[toc] | [prev] | [next] | [standalone]


#4557

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-01-21 15:53 -0500
Message-ID<jff8ks$8jc$1@dont-email.me>
In reply to#4556
On 1/21/2012 2:31 PM, Chuck Anderson wrote:
> J.O. Aho wrote:
>> Chuck Anderson wrote:
>>> Michael Fesser wrote:
>>>> .oO(Captain Paralytic)
>>>>
>>>>> On Jan 20, 10:25 am, Michael Fesser <neti...@gmx.de> wrote:
>>>>>> No. You have to explicitly send the correct header or some browsers
>>>>>> might ignore the CSS. For example
>>>>>>
>>>>>> header('Content-Type: text/css; charset=UTF-8')
>>>>> Oh OK. Any ideas which ones?
>>>>
>>>> In the past Gecko browsers (i.e. Firefox) were a bit picky about the
>>>> correct CSS content type. If the file wasn't delivered as text/css, it
>>>> was ignored.
>>>>
>>> I have successfully used:
>>> header("Content-type: text/css");
>>>
>>> After implementing a php based style sheet a couple of different
>>> times it
>>> seemed wasteful, and a bit of a kludge. If the style sheet is ultimately
>>> static, it is wasteful to keep generating one every time it is used.
>>> Now I use
>>> a php script to generate the style sheet file for me. If I want to make
>>> changes I edit the php based file (or any included definition files,
>>> e.g.,
>>> colors.php) and run it.
>>>
>>
>> I have to say it feels quite much of extra work, writing the php
>> script which generates the css, as you need to edit the php file, then
>> IMHO you can quite easily edit a css instead.
>
> I edit one php file and then simply invoke it. There is very little more
> "work."
>
> In preparation, I write a script that opens a file for writing (the css
> file) and then one long heredoc to create it's contents. This creates an
> easily reusable system for very little extra work.
>
>> I could see a bit more point of your script if you have a database as
>> a backend, where you store the values and recreate the css each time
>> the values change.
>
> It's not a database, but I include color definitions from a separate php
> file.
>

I agree with J.O.  Seems overly complicated to have to edit a PHP file 
which then generates the CSS.  Much easier just to edit the CSS - 
especially when you have syntax-sensitive editors for CSS available.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#4558

FromMichael Fesser <netizen@gmx.de>
Date2012-01-21 22:22 +0100
Message-ID<agamh75s155va4u0c6p860sfcbpqvi6gsc@mfesser.de>
In reply to#4557
.oO(Jerry Stuckle)

>On 1/21/2012 2:31 PM, Chuck Anderson wrote:
>> J.O. Aho wrote:
>>>
>>> I have to say it feels quite much of extra work, writing the php
>>> script which generates the css, as you need to edit the php file, then
>>> IMHO you can quite easily edit a css instead.
>>
>> I edit one php file and then simply invoke it. There is very little more
>> "work."
>>
>> [...]
>
>I agree with J.O.  Seems overly complicated to have to edit a PHP file 
>which then generates the CSS.  Much easier just to edit the CSS - 
>especially when you have syntax-sensitive editors for CSS available.

The whole point of using PHP for creating the CSS is to avoid having to
edit a dozen places in the CSS to change some color for example. Instead
you make use of PHP and variables. Much simpler.

And if you still want a "static" CSS for performance reasons, you have
to preprocess it. Calling a script for doing this is not much work.
Dependent on the used IDE this could even be automated in the build and
upload process.

Micha

-- 
http://mfesser.de/blickwinkel

[toc] | [prev] | [next] | [standalone]


#4559

From"Beauregard T. Shagnasty" <a.nony.mous@example.invalid>
Date2012-01-21 21:37 +0000
Message-ID<jffb68$hu2$2@dont-email.me>
In reply to#4558
Michael Fesser wrote:

> The whole point of using PHP for creating the CSS is to avoid having to
> edit a dozen places in the CSS to change some color for example. Instead
> you make use of PHP and variables. Much simpler.

For one color, in a properly "optimized" CSS file, shouldn't there just 
be one place there as well?  That's the way mine are. I place all the 
specific styling as one would normally expect: by elements, IDs and 
classes, then end the file with all the color designators. Something like 
this little sample:

body { 
   background: white; color: black;
}
id1, id2, class1, class2, class3, class4 {
   color: blue;
}
p, li {
   color: green;
}

Then of course just use an 'include' in the PHP code to the CSS file.

-- 
   -bts
   -This space for rent, but the price is high

[toc] | [prev] | [next] | [standalone]


#4573

FromMichael Fesser <netizen@gmx.de>
Date2012-01-22 22:35 +0100
Message-ID<5evoh79crkq7aa00lds9tgmbvct7i8ce0n@mfesser.de>
In reply to#4559
.oO(Beauregard T. Shagnasty)

>Michael Fesser wrote:
>
>> The whole point of using PHP for creating the CSS is to avoid having to
>> edit a dozen places in the CSS to change some color for example. Instead
>> you make use of PHP and variables. Much simpler.
>
>For one color, in a properly "optimized" CSS file, shouldn't there just 
>be one place there as well?

Maybe it's personal preference, but I wouldn't do it. For me it would
mean to "sort" the CSS by properties instead of elements. But I don't
want to spread the properties of an element across the entire CSS: the
background color here, the foreground color there, the border style
somewhere else. Instead I keep them together.

Micha

-- 
http://mfesser.de/blickwinkel

[toc] | [prev] | [next] | [standalone]


#4580

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-01-22 19:19 -0500
Message-ID<jfi93i$irg$1@dont-email.me>
In reply to#4573
On 1/22/2012 4:35 PM, Michael Fesser wrote:
> .oO(Beauregard T. Shagnasty)
>
>> Michael Fesser wrote:
>>
>>> The whole point of using PHP for creating the CSS is to avoid having to
>>> edit a dozen places in the CSS to change some color for example. Instead
>>> you make use of PHP and variables. Much simpler.
>>
>> For one color, in a properly "optimized" CSS file, shouldn't there just
>> be one place there as well?
>
> Maybe it's personal preference, but I wouldn't do it. For me it would
> mean to "sort" the CSS by properties instead of elements. But I don't
> want to spread the properties of an element across the entire CSS: the
> background color here, the foreground color there, the border style
> somewhere else. Instead I keep them together.
>
> Micha
>

Yes, it's a matter of style.  But I prefer to keep all items of the same 
color together. That way when I want to change the color there's only 
one place to change the code when I want to change colors.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#4560

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-01-21 17:08 -0500
Message-ID<jffd0o$2qo$1@dont-email.me>
In reply to#4558
On 1/21/2012 4:22 PM, Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> On 1/21/2012 2:31 PM, Chuck Anderson wrote:
>>> J.O. Aho wrote:
>>>>
>>>> I have to say it feels quite much of extra work, writing the php
>>>> script which generates the css, as you need to edit the php file, then
>>>> IMHO you can quite easily edit a css instead.
>>>
>>> I edit one php file and then simply invoke it. There is very little more
>>> "work."
>>>
>>> [...]
>>
>> I agree with J.O.  Seems overly complicated to have to edit a PHP file
>> which then generates the CSS.  Much easier just to edit the CSS -
>> especially when you have syntax-sensitive editors for CSS available.
>
> The whole point of using PHP for creating the CSS is to avoid having to
> edit a dozen places in the CSS to change some color for example. Instead
> you make use of PHP and variables. Much simpler.
>
> And if you still want a "static" CSS for performance reasons, you have
> to preprocess it. Calling a script for doing this is not much work.
> Dependent on the used IDE this could even be automated in the build and
> upload process.
>
> Micha
>

Create your .css properly and you don't need to do that.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#4561

FromChuck Anderson <cycletourist@invalid.invalid>
Date2012-01-21 18:17 -0700
Message-ID<jffo3d$up2$1@dont-email.me>
In reply to#4560
Jerry Stuckle wrote:
> On 1/21/2012 4:22 PM, Michael Fesser wrote:
>> .oO(Jerry Stuckle)
>>
>>> On 1/21/2012 2:31 PM, Chuck Anderson wrote:
>>>> J.O. Aho wrote:
>>>>>
>>>>> I have to say it feels quite much of extra work, writing the php
>>>>> script which generates the css, as you need to edit the php file, 
>>>>> then
>>>>> IMHO you can quite easily edit a css instead.
>>>>
>>>> I edit one php file and then simply invoke it. There is very little 
>>>> more
>>>> "work."
>>>>
>>>> [...]
>>>
>>> I agree with J.O. Seems overly complicated to have to edit a PHP file
>>> which then generates the CSS. Much easier just to edit the CSS -
>>> especially when you have syntax-sensitive editors for CSS available.
>>
>> The whole point of using PHP for creating the CSS is to avoid having to
>> edit a dozen places in the CSS to change some color for example. Instead
>> you make use of PHP and variables. Much simpler.
>>
>> And if you still want a "static" CSS for performance reasons, you have
>> to preprocess it. Calling a script for doing this is not much work.
>> Dependent on the used IDE this could even be automated in the build and
>> upload process.
>>
>> Micha
>>
>
> Create your .css properly and you don't need to do that.
>

I use my css generating file, which I would hardly call a script (fopen, 
fwrite, fclose), as a template for whatever miscellaneous project I end 
up working on. I write lots of browser based web apps and this makes for 
a real shortcut, as all I have to do is plug in some basic colors and I 
get a style sheet with all the selectors I'm used to having available in 
whatever color scheme I choose. At any time during or after development 
I can stop using the script and just edit the style sheet directly - but 
as long as I'm fiddling with colors I leave it dynamic.

It seems an unnecessary waste of server resources to keep calling the 
php preprocesssor every time a page loads the .php style sheet. And it 
also seems like using a header of Content-type: text/css for a php file 
is a bit of a kludge.

But, to each their own - and for their own purposes. My method works 
great for my needs.

-- 
*****************************
 Chuck Anderson • Boulder, CO
  http://cycletourist.com
 Turn Off, Tune Out, Drop In
*****************************

[toc] | [prev] | [next] | [standalone]


#4563

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-01-21 23:14 -0500
Message-ID<jfg2eh$6t0$1@dont-email.me>
In reply to#4561
On 1/21/2012 8:17 PM, Chuck Anderson wrote:
> Jerry Stuckle wrote:
>> On 1/21/2012 4:22 PM, Michael Fesser wrote:
>>> .oO(Jerry Stuckle)
>>>
>>>> On 1/21/2012 2:31 PM, Chuck Anderson wrote:
>>>>> J.O. Aho wrote:
>>>>>>
>>>>>> I have to say it feels quite much of extra work, writing the php
>>>>>> script which generates the css, as you need to edit the php file,
>>>>>> then
>>>>>> IMHO you can quite easily edit a css instead.
>>>>>
>>>>> I edit one php file and then simply invoke it. There is very little
>>>>> more
>>>>> "work."
>>>>>
>>>>> [...]
>>>>
>>>> I agree with J.O. Seems overly complicated to have to edit a PHP file
>>>> which then generates the CSS. Much easier just to edit the CSS -
>>>> especially when you have syntax-sensitive editors for CSS available.
>>>
>>> The whole point of using PHP for creating the CSS is to avoid having to
>>> edit a dozen places in the CSS to change some color for example. Instead
>>> you make use of PHP and variables. Much simpler.
>>>
>>> And if you still want a "static" CSS for performance reasons, you have
>>> to preprocess it. Calling a script for doing this is not much work.
>>> Dependent on the used IDE this could even be automated in the build and
>>> upload process.
>>>
>>> Micha
>>>
>>
>> Create your .css properly and you don't need to do that.
>>
>
> I use my css generating file, which I would hardly call a script (fopen,
> fwrite, fclose), as a template for whatever miscellaneous project I end
> up working on. I write lots of browser based web apps and this makes for
> a real shortcut, as all I have to do is plug in some basic colors and I
> get a style sheet with all the selectors I'm used to having available in
> whatever color scheme I choose. At any time during or after development
> I can stop using the script and just edit the style sheet directly - but
> as long as I'm fiddling with colors I leave it dynamic.
>
> It seems an unnecessary waste of server resources to keep calling the
> php preprocesssor every time a page loads the .php style sheet. And it
> also seems like using a header of Content-type: text/css for a php file
> is a bit of a kludge.
>
> But, to each their own - and for their own purposes. My method works
> great for my needs.
>

I have a template css file I just edit as required.  Actually, I have 
several, with different options.

When I need a new style sheet, I just pick the closest template to what 
I want, modify it and try it out.  I even keep a copy open in an editor 
on my development system - that way when I want to try something 
different, make a change and save it.  The change is immediately available.

The only thing I use PHP for is to determine which template to load for 
a user if I have different themes available on the website.

And a content-type header is needed for any file that's not html. 
That's just normal operation (in any language).

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.php


csiph-web