[Zope] simple dtml question

Martijn Pieters mj@antraciet.nl
Tue, 24 Aug 1999 18:18:57 +0200


At 17:23 24-8-99 , Tim Wilson wrote:
>Hi everyone,
>
>Why doesn't this work? I hesitate to ask because I'm sure it's a simple
>answer. It's a DTML Method in the / folder. The button image is also in /.
>
><center>
><a href="http://www.adobe.com/prodindex/acrobat/readstep.html"><img
>border=0 src="<dtml-var acroread_button>"></a>
></center>

What happens when you call an image (like <dtml-var acroread_button> does),
Zope will insert a complete image tag for you:

  <img src="/acroread_button" width=xx height=xx 
   alt="title of the acroread_button object">

Because you insert this inside another IMG tag, you end up with the following:

<center>
<a href="http://www.adobe.com/prodindex/acrobat/readstep.html"><img
border=0 src="<img src="/acroread_button" height=xx width=xx alt="title of
the acroread_button object">"></a>
</center>

which makes no sense to your browser.

You want to do one of the following:

<center>
<a href="http://www.adobe.com/prodindex/acrobat/readstep.html"><img
border=0 src="<dtml-var "acroread_button.absolute_url()">"></a>
</center>

which inserts the URL of the image object, or:

<center>
<a href="http://www.adobe.com/prodindex/acrobat/readstep.html">
<dtml-var acroread_button></a>
</center>

which inserts the whole IMG tag, including width and height, but you'd be
missing your 'border=0' and have an alt attribute extra. The following code
will insert an IMG tag with 'border=0', and without the alt attribute:

<center>
<a href="http://www.adobe.com/prodindex/acrobat/readstep.html">
<dtml-var "acroread_button.tag(alt='', border=0)"></a>
</center>


-- 
Martijn Pieters, Web Developer 
| Antraciet http://www.antraciet.nl 
| T: +31 35 7502100 F: +31 35 7502111 
| mj@antraciet.nl http://www.antraciet.nl/~mj 
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 
---------------------------------------------