• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Inline Xen:elseif in a template


Active member
Is it okay to use a long "xen:elseif" chain in a template like below?

class = {xen:if '{$user.customFields.my_id1} == "A"', 'class1', {xen:if '{$user.customFields.my_id2} == "A"', 'class2', {xen:if '{$user.customFields.my_id3} == "A"', 'class3', {xen:if '{$user.customFields.my_id4} == "A"', 'class4'}}}}


Active member
You could do it, but it might be better to use a helper function if you have that many cases.

Then you would just do something like class='{xen:helper customfieldsclass, $user.customFields}', and write a helper function to return the desired class based on the contents of customFields.