Re: [Zope] Yet another way to insert a variable from an expression
| Odesílatel: DA Loeffler <David.Loeffler@bristol.ac.uk> | | <dtml-var expr="_[id()+'.gif']" missing> | <dtml-var "_.getattr(this().aq_parent, id() + '.gif')"> Genius! It works both, maybe complicated one will work better (restricted acquisition), but... | > > file1 | > > file1.gif | > > file2 | > > file3 | > > file3.gif But it does have error when filename does not have image filename.gif, like file2 I was try dtml-if, dtml-let+dtml-if (and nested dtml-in - it does not work because one is ObjectValue"DTML Document" and second is ObjectValue"Image"). <dtml-if "_.string.find(_.getattr(this().aq_parent, id() + '.gif'), '.gif')>0"> In attachment is a small file with my some tryouts (sorry, You do not an idiot, but me :) Many thanks Jaroslav Lukesh
Sorry, the "missing" attribute doesn't work, but you can always just wrap it in a <dtml-try> block that will catch the error and not do anything with it, like <dtml-try> <dtml-var expr="_[id()+'.gif']"> <dtml-except> </dtml-try> It's a bit of a kludge but it works. On Fri, 12 Jul 2002, Jaroslav Lukesh wrote:
| Odes�latel: DA Loeffler <David.Loeffler@bristol.ac.uk> | | <dtml-var expr="_[id()+'.gif']" missing>
| <dtml-var "_.getattr(this().aq_parent, id() + '.gif')">
Genius! It works both, maybe complicated one will work better (restricted acquisition), but...
| > > file1 | > > file1.gif | > > file2 | > > file3 | > > file3.gif
But it does have error when filename does not have image filename.gif, like file2
I was try dtml-if, dtml-let+dtml-if (and nested dtml-in - it does not work because one is ObjectValue"DTML Document" and second is ObjectValue"Image").
<dtml-if "_.string.find(_.getattr(this().aq_parent, id() + '.gif'), '.gif')>0">
In attachment is a small file with my some tryouts (sorry, You do not an idiot, but me :)
Many thanks
Jaroslav Lukesh
participants (2)
-
DA Loeffler -
Jaroslav Lukesh