In both methods $film->runtime_sec() needs to be evaluated twice. Is there a shorter way that works for Kirby fields, maybe something like the short circuit pattern in JavaScript?
Great, thanks! Both methods will make my code a lot cleaner.
One more related question though. Say I want to check if a field is empty or not and if not, I want to return the value with some alteration. See this example:
In this case I cannot use or, as I would need to alter the field value (add a € symbol). Is there any short and elegant way to achieve this, without having to do $product->price() twice?
I think I might just do that, because I really need this all the time: “Take some field value with a tiny alteration or if the field is empty some default fallback”. Might even be a good on board method I think.