Articles Anywhere

Nested conditions

2 weeks 4 days ago #77846

Hans Kuijpers's Avatar Hans Kuijpers

if one of the custom fields is set, I would like to add an icon with a tooltip.

I'm using the following code:

{if tld-eenmalige-opzetkosten OR tld-kosten-bij-wijziging-van-registrant OR tld-bijzonderheden}
<span data-toggle="tooltip" data-html="true" data-placement="right" data-original-title="
  <strong>{tld-eenmalige-opzetkosten label="only"}</strong> {tld-eenmalige-opzetkosten}
  <strong>{tld-kosten-bij-wijziging-van-registrant label="only"}</strong> {tld-kosten-bij-wijziging-van-registrant}}
  <strong>{tld-bijzonderheden label="only"}</strong> {tld-bijzonderheden}
"><i class="fa fa-info-circle"></i></span>
{/if}

But I would like to use nested conditions to add hard coded text when one of the custom fields has no value:
{if tld-eenmalige-opzetkosten OR tld-kosten-bij-wijziging-van-registrant OR tld-bijzonderheden}
<span data-toggle="tooltip" data-html="true" data-placement="right" data-original-title="
  <strong>{tld-eenmalige-opzetkosten label="only"}</strong> {if tld-eenmalige-opzetkosten}{tld-eenmalige-opzetkosten}{else}geen{/if}
  <strong>{tld-kosten-bij-wijziging-van-registrant label="only"}</strong> {if tld-kosten-bij-wijziging-van-registrant}{tld-kosten-bij-wijziging-van-registrant}{else}geen{/if}
  <strong>{tld-bijzonderheden label="only"}</strong> {if tld-bijzonderheden}{tld-bijzonderheden}{else}geen{/if}
"><i class="fa fa-info-circle"></i></span>
{/if}

The second piece of code breaks, since the first closing if will close the first if-statement.
It would be cool if we could use nested conditions.

Mind.... the icon with tooltip should only appear when one of the custom fields has a value. AND when one of the custom fields has no value the hard-coded text "geen" (Dutch for 'none') should appear.

2 weeks 4 days ago #77848

Peter van Westen's Avatar Peter van Westen Admin

It is not possible to nest conditions.
When things are getting as complex as this, it is probably better to code this directly in php and not use Articles Anywhere.

2 weeks 2 days ago #77945

Hans Kuijpers's Avatar Hans Kuijpers

How could you check if the rendered value of an item is set?
empty and !== null doesn't seem to work
a var_dump of {tld-eenmalige-opzetkosten} will result in a string with a length of 27, although the output is ''.

2 weeks 2 days ago #77947

Peter van Westen's Avatar Peter van Westen Admin

There is no option for that. Using the custom fields in {if} tags will compare to the raw value. Not the final rendered value.