[ZPT] Structural Logic: Really, It Is...

beno zope@thewebsons.com
Sun, 06 Oct 2002 14:53:09 -0400


At 08:41 PM 10/6/2002 +0200, you wrote:

>Hi Beno,
>
>  > Hi;
>  > I'm hell-bent on dynamically structuring my Web sites such that they 
> scale
>  > to the browser's resolution. This includes font size. Back when I hacked
>  > strictly in DTML, that was easy. I wrote an External Method and, as an
>  > example, called it thusly in an <img> tag:
>  >
>  > width=<dtml-var "sizeCalc(204,size(_.None,_))">
>  >
>  > where 204 was the width for browsers surfing at 1024*786. Obviously, 
> if I'm
>  > to write page templates, it would be really convenient if I could 
> write one
>  > that satisfied all (as I've done with DTML) instead of writing 5 separate
>  > templates! How do I create the same logic within ZPT?
>  >
>
>  Ever heard of the "tal:attributes" tag? You should be able to write
>something like:
>  <img width="204" tal:attributes"width python:here.sizeCalc(204,
>here.size(None, context))" src=..." />

Yeah, heard of it, but this is my first time around. I tried this code:

<font style="font: tal:attributes='python:here.sizeCalc(44,here.size(None, 
context))'" >
This is Page Template <em tal:content="template/id">template id</em>.</font>

and it didn't render as I'd hoped. What am I missing?


>(I guess what "_" is in DTML binds to "context" in page templates,
>though I am not sure ...)
>
>  > For basically the same reason, I would like to include logic similar 
> to the
>  > below:
>  >
>  > <span class="frame">
>  >   <iframe src=<span tal:replace="here/title">Title</span>_frame width=934
>  > height=526 frameborder=0 marginheight=0 marginwidth=0 
> scrolling=yes></iframe>
>  > </span>
>  >
>  > Of course, the problem is that I can't nest that tal:replace statement.
>
>  ... could be written as:
>
><iframe src="dummy" tal:attributes"src string:${here/title}_frame"
>width=934 height=526 frameborder=0 marginheight=0 marginwidth=0
>scrolling=yes />

Thanks, I'll work on that one.
beno