-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dragos Chirila wrote:
> Hi everybody,
> 
> I am stuck with the following problem. I would appreciate it very much
> if you could help me with it.
> 
> So I have a ZPT where a macro is defined with several slots; one of
> the slots like below:
> 
> <tal:block metal:define-slot="slot_issue">
>       SLOT DEFAULT CONTENT
> </tal:block>
> 
> The common way to put other content in the slot is:
> 
> <tal:block metal:fill-slot="slot_issue">
>       CUSTOM SLOT CONTENT
> </tal:block>
> 
> Now, in a ZPT that uses the above marco I want to replace the default
> slot content with other stuff
> *only* if a condition is fulfilled:
> 
> <tal:block tal:condition="<condition-code>" metal:fill-slot="slot_issue">
>       CUSTOM SLOT CONTENT
> </tal:block>
> 
> If the <condition-code> returns True then the "CUSTOM SLOT CONTENT" is
> put instead of the default slot content - correct.
> If the <condition-code> returns False then nothing will be displayed -
> this is not correct?!.
> 
> I also tried somthing like:
> 
> <tal:block tal:condition="<condition-code>">
>       <tal:block metal:fill-slot="slot_issue">
>               CUSTOM SLOT CONTENT
>       </tal:block>
> </tal:block>
> 
> In this case the content of the slot is "CUSTOM SLOT CONTENT" in both
> cases - the result is True or False.
> 
> The only solution that I can think of is not elegant at all because I
> have to duplicate the slot_issue's default content:
> 
> <tal:block metal:fill-slot="slot_issue">
>       <tal:block tal:condition="<condition-code>">
>               CUSTOM SLOT CONTENT
>       </tal:block>
>       <tal:block tal:condition="python:not <condition-code>">
>               SLOT DEFAULT CONTENT
>       </tal:block>
> </tal:block>
> 
> Is there other wat to accomplish this?

You might modify the macro to allow this, making the default content a
separate macro::

  <html metal:define-macro="slotted">
  <body>
  <h1> Slotted </h1>
  <div metal:define-slot="slot_issue">
  <metal:default metal:define-macro="default_issue">
   DEFAULT SLOT CONTENT
  <metal:default>
  </div>
  </body>
  </html>

The template which includes the macro would then be::

  <html metal:use-macro="context/other_template/macros/slotted">
  <body>
  <div metal:fill-slot="slot_issue">
  <tal:block condition="<condition-code>">
    CUSTOM SLOT CONTENT
  </tal:block>
  <tal:block condition="not:<condition-code>">
   <div metal:use-macro="context/other_template/macros/default_issue"/>
  </tal:block>
  </div>
  </body>
  </html>

It may help to remember that macros are actually "inlined" into the
including template, rather than being "called" as a function would be.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF3YQz+gerLs4ltQ4RAjetAKCpQdrYi6Vl0LeWkAvE6sFVt2RwOACg0GgZ
tYguZqyYKbTohGOmh6in5gw=
=Q5Bv
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist  -  Zope@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 )

Reply via email to