[ZPT] playing with stylesheets in ZPT?

richard@bizarsoftware.com.au richard@bizarsoftware.com.au
Tue, 10 Apr 2001 09:42:26 +1000


Martijn Pieters wrote:
> On Mon, Apr 09, 2001 at 06:21:50PM +1000, richard@bizarsoftware.com.au wrote:
> > Let's say that we have an object tree where every page in the tree has the
> > following in it:
> >
> > <style type="text/css">
> > body {
> >   background-repeat: no-repeat; background-image: url(images/main_back.gif)
> > }
> > </style>
> 
> Hmm.. I'd make the stylesheet a Python Script or something..

Can't - the stylesheet is created in the page by a web designer. We want
them to be able to create the page with the minimum of fuss. The entire ZPT
layout must be viewable and editable in Dreamweaver, both before it's
"uploaded" to the Product which is rendering it and afterwards. I can't
just remove the stylesheet information from the page and place it
elsewhere.

We can't move the CSS out to a linked stylesheet, because Netscape is
really picky about where you put background image declarations, and a
linked stylesheet doesn't cut its mustard. Ultimately this is all Netscape
4.7's fault :)


> Or you could
> go the CMF way and make the CSS Stylesheet external but include it in the
> case of Netscape 4 clients. I converted that to ZPT for the Internet World
> demo and that worked great.

As a rule, we never, ever, use linked stylesheets. Even IE gets it wrong
sometimes.


> I used the following code to include the stylesheet (which keeps working
> in Dreamweaver and GoLive if you fill in a correct href attribute on the
> tag):
> 
>   <link rel="stylesheet" href="default_stylesheet" type="text/css"
>         tal:replace="structure here/css_inline_or_link" />

If the stylesheet is linked in, this is fine. But if the stylesheet is in
the page, I can't do anything in ZPT at the moment to this end.


> [code snipped]

We have a very similar thing for the ZPT - the page is parsed at cook time
and tal:attributes statements are inserted into <img> and <link> tags to
make them do the "correct" thing at render time. I just need something I
can do for the _content_ of the <style> tag.

At the moment, it's looking like I'm going to have to manually parse the
ZPT to pick out the <style> tag and its contents. Then create an internal
list of the <style> tag contents and insert a tal:content statement into
the ZPT source. The tal:content statement will then look up the appropriate
<style> tag contents internally and parse/mangle them.

This would be so much easier if I could use the TAL parser rather than
having to write my own...


    Richard

-- 
Richard Jones
richard@bizarsoftware.com.au
Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)