[Zope] metal:fill-slot and tal:condition

Dragos Chirila objectvalues at gmail.com
Thu Feb 22 04:51:12 EST 2007


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?

Thank you very much,
Dragos


More information about the Zope mailing list