Hi Kirby-Gurus,
I am using the ecco (e) function a lot like and noticed that the functions in the cases are executed even if the condition for them is not met:
Of course in this example I could easily use return values to prevent this snippet from outputting bar but I am not able to prevent errors in examples like this, where the $page-element does not have any images assigned:
Yes, you cannot use ecco() or e() in all situations. It’s ok for empty fields, but in your case, because the options are rendered before the evaluation, the call to the first() method is on a non-existing object, which will result in an error.
Is just vaguely remember from another programming language that function parameters could be marked as “Don’t execute until I say” which would be a great fit for ecco if something like this is possible in php, too.