XF 1.5 Optimize conditional block

abdfahim

Active member
#1
I have a pretty ugly looking conditional block, which serves my purpose though. Is there any nice alternative?

Code:
<xen:if is="{$contentTemplate} == 'forum_list' OR {$contentTemplate} == 'forum_view' OR {$contentTemplate} == 'thread_view' OR {$contentTemplate} == 'search_results' OR {$contentTemplate} == 'find_new_posts_none' OR {$contentTemplate} == 'find_new_posts'">
DO SOMETHING
</xen:if>
 

Arty

Well-known member
#2
You can try using in_array, but I'm not sure how array can be set inside template, so you might need to create array in php code.
 

Brogan

XenForo moderator
Staff member
#3
Code:
<xen:if is="in_array({$contentTemplate}, array('message_page', 'error', 'search_form', 'search_form_post', 'search_form_profile_post', 'search_results', 'register_form', 'register_facebook', 'register_twitter', 'register_google', 'login', 'login_two_step', 'error_with_login', 'contact'))">
Like that.
 
Top