XF 1.5 Inline Xen:elseif in a template

abdfahim

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

Code:
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'}}}}
 
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.
 
Top Bottom