> -----Original Message-----
> From: Alex Mendez [mailto:[EMAIL PROTECTED]]
> Sent: 02 June 2000 12:28
> To: Lista Zope
> Subject: [Zope-dev] Repeating a piece of HTML code
> Hello, it's the first time I write here and I'm a
> newbie at Zope, so maybe I'm asking a stupid
> question...

The only stupid question is the one that's never asked.
You might, however, find that questions like this are more suited to the
general [EMAIL PROTECTED] mailing list.

> Case is I retrieve from my movie database the value of
> the movie from 1 to 5 stars. I would like to repeat
> that n times the code <img SRC="star.gif" height=15
> width=15> so the number of stars would appear:
> 1 - *
> 2 - **
> 3 - ***
> 4 - ****
> 5 - *****
> Is there any way to do so in Zope? Does the <dtml-in>
> tag anything to do with it?

The <dtml-in> tag is certainly what you're looking for if you want to do
this in DTML. Something like the following will do what you're looking for:

  <dtml-let stars="5">

    <dtml-in "_.range(stars)">
      <IMG SRC="star.gif" HEIGHT="15" WIDTH="15">


The <dtml-in "_.range(stars)"> ... </dtml-in> forms a loop that gets
repeated 5 times by using the python range function -- generally, anything
inside double quotes in DTML is treated as a python expression. You'll find
that the "_." notation, which accesses the global namespace, allows you to
make use of all sorts of python functions.

You would replace the <dtml-let stars="5"> with a call to your database to
find the actual number of stars.


-- Marcus

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to