if text: display text else icon with tal
I have a problem with my Page Template: I want the visitors to have the opportunity to get one level up. In my product I have a field that is called 'level_up_txt'. If this field is filled in I want to use that, but when they leave the field empty they have to get a levelup icon. How can I arrange this in TAL? I've tried it like this: <a class="gnawlink" href="" tal:attributes="href container/absolute_url" tal:content="container/level_up_txt"> <img src="icon" width="16" height="16" border="0" alt="item" tal:attributes="src here/upfolder; alt here/meta_type" /></a> Where upfolder is the icon that I want to use. Can anybody help me? Greetz Nico
Nico de Boer writes:
... if/else idiom in ZPT ... When you want:
if cond then XXXX else YYYY you can use in ZPT: <tal:div tal:condition="cond">XXXX</tal:div> <tal:div tal:condition="not:cond">YYYY</tal:div> To check for existence, you can use "exists: path". Dieter
When you want:
if cond then XXXX else YYYY
you can use in ZPT:
<tal:div tal:condition="cond">XXXX</tal:div> <tal:div tal:condition="not:cond">YYYY</tal:div>
To check for existence, you can use "exists: path".
Dieter
Could someone expand on *why* the if/then/else construct is not literally possible in ZPT? Is it considered to be already too much logic which the designers of ZPT want us to use scripts for? Or is it an SGML-thing? Roger
Roger Erens writes:
When you want:
if cond then XXXX else YYYY
you can use in ZPT:
<tal:div tal:condition="cond">XXXX</tal:div> <tal:div tal:condition="not:cond">YYYY</tal:div>
To check for existence, you can use "exists: path".
Dieter
Could someone expand on *why* the if/then/else construct is not literally possible in ZPT?
Search the ZPT mailing list archive. It was explained there in length... Dieter
participants (3)
-
Dieter Maurer -
Nico de Boer -
Roger Erens