[ZPT] playing with stylesheets in ZPT?

richard@bizarsoftware.com.au richard@bizarsoftware.com.au
Mon, 09 Apr 2001 18:21:50 +1000


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>

The images dictionary is an acquired attribute. If we're to avoid reloading
the background image for every page down the acuisition tree, then we need
to modify that 'images/main_back.gif' url so it is the same on each page.
We can do it for <img> tags by preprocessing the page and inserting
tal:attributes attributes to do the job. Not so for the contents of the
style tag.

In the Bad Ol Days of DTML, I just had a dtml statement in there, like
  url(<dtml-var "path_to_images(REQUEST)">/main_back.gif)
which worked just fine and dandy... ;)

Now, remembering that this CSS may be entered by any random Web Designer
and that it may contain any number of other statements, possibly with a
bunch of other url(images/blah.gif) in them...

It's currently impossible as far as I can tell, to have ZPT do what I used
to do in DTML.

What _would_ make it possible, would be to be able to, say,

<style type="text/css" tal:process="here/image_path_fix>
body {
  background-repeat: no-repeat; background-image: url(images/main_back.gif)
}
</style>

Where image_path_fix is a method that accepts the content of the <style>
... </style> tag, and spits out some possibly modified content...

Thoughts?


   Richard

ps. of course, if someone else has another solution to the "moving images
directory" problem, I'd _love_ to hear it :)

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