Forum OpenACS Development: Re: template::head::add_css problem

Collapse
Posted by Emmanuelle Raffenne on
Usually, the designer/developer will call add_css in the order she wants the CSS to appear in the HEAD block. So keeping track of the order they were added sounds reasonable to me.

On the other hand, the order 1.stylesheet media=all 2.other media 3.alternative, also sounds the right way to go (switching #2 and #3 not since main css are not always for all media but may have media="screen", which is the case in Zen). However, as Gustaf said, the order of tcl/adp evaluation is "from inside to out" so to keep the logical order proposed by Don would be tricky. Maybe a combination of the 2 would work.

I don't like the idea of adding a priority parameter for stylesheets because 1. it would override the order proposed by Don (which sounds right to me), and 2. what criterion to use when 2 stylesheets added from different scripts have the same priority number.

Collapse
Posted by Don Baccus on
Well, my suggestion was to order the CSS when they're output by the master template, I haven't looked but I assume at some point the array used to store is transformed into a multirow, and the LINKs can be ordered there. I assume the add_css call uses an array to avoid linking more than once (i.e. a second call to add_css with the same stylesheet will just overwrite the existing entry).

Normally, I'd say this makes sense:

Usually, the designer/developer will call add_css in the order she wants the CSS to appear in the HEAD block. So keeping track of the order they were added sounds reasonable to me.
But when a user customizes their portal page, moving portlets around, doing so will re-order the order in which the portlets (and therefore template::head::add_css commands) will be executed.

So the package developer doesn't really have control over the ordering, do they????

I would also say that package CSS shouldn't overwrite normal CSS anyway. If I visit a package page, it shouldn't (for instance) change the developer toolbar to screaming red or whatever! It should only define CSS specific to the package.

So my perhaps overly simplistic view is that only alternate stylesheets and media-specific stylesheets should overwrite our normal CSS classes.

I guess "media type=all" should preceed "screen", "print" etc in the alternative stylesheet ordering, too???

Collapse
Posted by Don Baccus on
Slight modification - of course the package developer has control over how CSS within *their* package gets ordered, but there's no control over ordering outside that in practice, even if we preserve order.