Stephan Goeldi writes:
I am pulling a list of names out of an SQL database to show their name and adress etc. In a specific zope folder are some pictures of SOME names. If there exists a picture for a certain name, it should be displayed. If not, there should be a placeholder. What is the correct syntax of this?
What I think of is something like this:
<dtml-in dep_cc> <LI><a href="mailto:<dtml-var EMAIL>"><dtml-var NAME></a> <dtml-if LOGIN.jpg> <img src="<dtml-var LOGIN>.jpg"> <dtml-else> no picture! </dtml-if> </dtml-in> Seems to me that you have several distinct problems:
* checking whether an object has a specific content item * the object id is not given as a constant but as an expression For the first problem, there is no complete solution in TTW code. You can use "aq_explicit" to approximate, but sometimes it will give wrong results. You need a file system based Python method to make it safe. Search for "aq_base" in the mailing list archives. For the second problem, you have the "getattr/hasattr" methods (of ´_´ or function in Python Scripts). You can try: <dtml-if expr="_.hasattr(your_specific_folder.aq_explicit, LOGIN+'.jpg'"> <img ...> By the way, your "img" tag will only work, when the images can be accessed throuch acquisition. It will fail when there are in a subfolder. Dieter