[Zope-CMF] small problem...How to check whether object is existing or not

Dieter Maurer dieter@handshake.de
Thu, 28 Jun 2001 22:51:31 +0200 (CEST)


Dhanu writes:
 > So 
 > 
 > "june/28/news1"  newsitem will have a corresponding image   "june/28/news1_image" posted.
 > 
 > So if a writer has posted an image corresponding to article,then everything goes right.Image is embeddded in to newsitem_view and gets displayed.
 > But if writer has posted only article,i have to check this and should not include image tag.
 > 
 > I tried this ,but to no success
 > 
 > <dtml-let image="URL+'_image'">
 > <dtml-if image>
 > <img src=&dtml-URL;_image align=left alt=&dtml-URL;_image >
 > </dtml-if>
 > </dtml-let>
If you can access the news id with "getId", then this is easy:

   <dtml-let myid=getId
             imgid="myid + '_image'
   >
     <dtml-if "_.has_key(imgid)">
       <img ....>
     </dtml-if>
   </dtml-let>

There is one problem with this approach:

  "imgid" may be acquired and not at all near the "news" item.

  But in your case, this probably is not a problem.


 > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Please do not post HTML!


Dieter