XF 1.5 Setting XF1 template variable based on nested ternaries


Well-known member

I'm trying to set a variable in an XF1 template to the result of some nested ternaries. I have it working in XF2, but can't get it to work in XF1.

Here's what I have:

<xen:set var="$nodePart">{{ $forum.node_id ? $forum.node_id : ($thread.node_id ? $thread.node_id : -1) }}</xen:set>

But it's not resolving that variable to the result of the ternary, it's resolving it to the string literal: {{ $forum.node_id ? $forum.node_id : ($thread.node_id ? $thread.node_id : -1) }}

I've tried single and double brackets, but still no luck. Maybe something screwy with my syntax?

Thanks in advance for the help.


PS. I also tried
$forum.node_id || $thread.node_id || -1
with single and double brackets, but still no luck.
Look for {xen:if in existing XF1 templates for hints.

Worth remembering that the template syntax in XF2 is much richer than it was in XF1 so things you may expect to work in XF1 may not exist at all.

Of course it's entirely your choice if you want to do this, but when I saw this over at TAZ it surprised me quite a bit that you'd be spending time on bringing this to XF1.

Given that XF1 is no longer supported and hasn't been for some years - not even receiving security updates anymore - we should be encouraging people to move away from XF1 rather than investing more time, money and effort on it.
Thanks, @Chris D. I found an alternative that should work.

Yeah, most of the forums we work with are on XF2, but we still have some that are on XF1. I think most want to migrate, but for various reasons can't do so immediately.
Top Bottom