[Zope] Tal:condition problem

KevinL darius@obsidian.com.au
20 Aug 2002 22:03:09 +1000


How about:

<div tal:define="macroName request/form/id">
  <metal:block use-macro="container/zptmac_memtask/macros/?macroName">
    List
  </metal:block>
</div>

Combined with renaming your "id" field in your forms (or your macro
names, either will do) so they match?  That munges the whole list of
tal:conditions down to something more manageable...

KJL

On Tue, 2002-08-20 at 21:56, Jens Vagelpohl wrote:
> i would *not* put both the tal:condition and metal:use-macro statements on 
> a single tag. separate them so each is on its own tag::
> 
> <div tal:condition="python:request.form['id'] == 't' or nothing">
>    <metal:block use-macro="container/zptmac_memtask/macros/zptmac_taskslist"
>  >
>      List
>    </metal:block>
> </div>
> 
> 
> jens
> 
> 
> On Tuesday, August 20, 2002, at 07:18 , zope wrote:
> 
> > Hi All
> > I am trying to execute a macro only if a condition is satisified.
> > The code I am using is:
> >  
> > <div tal:condition="python:request.form['id'] == 't' | nothing"  
> > metal:use-macro="container/zptmac_memtask/macros/zptmac_taskslist">
> >       List
> > </div>
> > <div tal:condition="python:request.form['id'] == 'p' | nothing"  
> > metal:use-macro="container/zptmac_mempending/macros/zptmac_pendlist">
> >       List
> > </div>
> > <div tal:condition="python:request.form['id'] == 'w' | nothing"  
> > metal:use-macro="container/zptmac_memweek/macros/zptmac_weeklist">
> >       List
> > </div>
> >  <div tal:condition="python:request.form['id'] == 'a' | nothing"  
> > metal:use-macro="container/zptmac_memall/macros/zptmac_alllist">
> >       List
> > </div> 
> > Depending on which value is passed with the form object i want that a 
> > particular macro be called.
> > But as soon as this page is rendered it shows me all the macros 
> > irrespective of whether I am sending any value for "id".
> > Is there some way I can check the condition and only show the required 
> > macro.
> > I m sure someone working on this particular area dealing with different 
> > conditions can help me out.
> >  
> > Best Regards
> >  
> > John Kunchandy
> >  
> >  
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>