22 Feb
2001
22 Feb
'01
1:24 p.m.
What the following code should do is test wheter an image exists and if it exists render it in the browser. If it doesn't exist it should show an empty default image. I found two ways to do it and both do it wrong in different ways
<dtml-let foto="'/Cis/fotos/afoto.jpg'">
<dtml-if expr="_.getitem('foto')"> <img src="&dtml-foto;"> <dtml-else> <img src="/Cis/fotos/Noface.jpg"> </dtml-if>
Try something like this: <dtml-if "_.hasattr(this(), '/Cis/fotos/afoto.jpg')"><dtml-let foto="/Cis/fotos/afoto.jpg"><dtml-var foto></dtml-let> <dtml-else> <img src="/Cis/fotos/Noface.jpg"> </dtml-if> Also, note that you can't embed dtml inside dtml. Ivan