[Zope] ZPT Help!

Michael Fox Michael at CenturySoftware.com.au
Tue Jul 20 22:31:27 EDT 2004


Not exactly... I define something called 'image' and display it using
the following code.

<span tal:define="image string:${here/id}.jpg">
  <img tal:attributes="src image" />
</span>

"id" being the id of my ZPT, with a .jpg extension to display an image
which shares the same id as a ZPT but with a .jpg extension.

But what I want to test is if the 'image' object does not exist within
the ZODB ... and display a "no image", image.

<span tal:condition="not:python:here.objectIds(image)">
  no image
</span>

But the above doesn't work.

-----Original Message-----
From: Dragos Chirila [mailto:d.chirila at finsiel.ro] 
Sent: Tuesday, 20 July 2004 5:58 PM
To: zope at zope.org; Michael Fox
Subject: Re: [Zope] ZPT Help!



If I understand corectly, you can have zpts without a coressponding 
image, but you cannot have an image without a corresponding zpt. If so, 
here is the piece of code that does the job:

<tal:block repeat="item python:here.objectValues('Image')">
  <tal:block define="zpt python:here[item.getId().replace('.jpg', '')]">

   Page Template: <span tal:replace="structure zpt"/><br>

   Image: <span tal:replace="structure item"/>

  </tal:block>
</tal:block>

So, iterate over all images in the folder. Extract the name of the zpt 
by removing the '.jpg' extension from the image id. Display the content 
of the zpt and then the image.


Hope this will help,
Dragos

Michael Fox wrote:
> Hi *,
> 
> I have a folder which contains a bunch of ZPT's and images, some of 
> which share the same unique ID as a ZPT which a ".jpg" extension. ie.
> 
> 1000
> 1000.jpg
> 1001
> 1002
> 1003
> 1004.jpg
> 1004
> 
> I have an index_html object which will render any ZPT in this 
> directory and the matching image, if available.
> 
> If there is no matching image I want to display an "image 
> unavailable", but can't get this to work.
> 
> <span tal:define="image string:${here/id}.jpg">
> 
>   <span tal:replace="image"></span>
> 
>   <span tal:condition="not:python:here.objectIds(image)">
>     There are currently no items available.
>   </span>
> 
> </span>
> 
> Regards,
> 
> Michael Fox               ^-^
> Analyst/Programmer       <`-`> ___
> Century Software          '  `'   '.
> Tel +61 2 9460 1422       `.  ` '  .'.
> Fax +61 2 9460 3098        ||.' '._/'.`.'
> www.CenturySoftware.com.au ""    "
> _______________________________________________
> Zope maillist  -  Zope at zope.org 
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
> 



More information about the Zope mailing list