[Zope] HELP needed to build image macro for documents

Dylan Reinhardt zope@dylanreinhardt.com
Wed, 26 Feb 2003 21:44:30 -0800


At 08:54 PM 2/26/2003, Steven Smith wrote:
>I'm creating documents and want to add images into the documents. I could 
>just create an image tag, but I want to take advantage of Zope/Plone and 
>what it can do.

That instinct will serve you well.

>  I understand the concept that everything in Plone is a object. As a 
> result everything can have a Title and Description.

Everything has an id and a title.  The id will be the name the image is 
called by when it is put in a url.  The title will be inserted into the alt 
attribute of the tag if you ask Zope to construct the tag for you (a good 
idea).

Additional properties can be added to pretty much any object.  They are 
then referenced as attributes of the object, thus:
    <dtml-var "object.property">

>I would like to figure out some simple DHTML(Python, ZPT, or other code) 
>code that I could use in my documents to reference the image and get back 
>the image with description. This small amount of Python/DHTML would need 
>to build a build a html table around the image, then in second cell under 
>image insert the text from image's description field (if description not 
>blank).

In DTML (assuming simple acquisition of image object my_image_name with a 
description property):

<table border=0>
    <tr>
       <td>
          <dtml-var my_img_name>
       </td>
    </tr>
    <tr>
       <td  align=center>
          <dtml-var "my_img_name.description">
       </td>
    </tr>
</table>

Bam!  You're done.  Take the rest of the morning off.  :-)

HTH,

Dylan