Checkbox test condition in template?

Author Message

Olaf Fichtner

Wednesday 23 February 2011 9:52:44 pm

I'm going slightly mad... I attempted to insert a checkbox data type into a document class and then to display something if the box is checked during document creation. The problem is, I can not find a test condition to use in the template.

"has_content" or "is_empty" do not work, because all checkboxes have content. Then I stumbled on "attribute(show)" and could at least see where a checked and a not checked box differ, but going through all kinds of operators I could still not get to different (checked/not checked) results. What I try looks very simple:

{if $node.data.map.check|eq('1')}

<div>display something</div>

{/if}

But it does not work. (The checkbox is named "check".) Also changing it to $node.data.map.check.value|eq('1')} (because the value for a checked box is 1) makes no difference. Unfortunately, most people only want to fetch such information for queries, so a forum search did not really bring me forward.

I am pretty sure this is something mindboggingly simple, but since I just can not find the answer I would be grateful for a helping hand...

Marko Žmak

Thursday 24 February 2011 5:57:05 am

The solution is like this:

{if $node.data_map.check.content}
    <div>display something</div>
{/if}

Note that it's "data_map" and not "data.map".

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Olaf Fichtner

Thursday 24 February 2011 6:05:16 pm

Aaarrrggghhhh, I knew it was something for which I would bang my head against the wall...

Thank you!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.