Advertising: Template blacklisting seems inefficient

Kirby

Well-known member
Affected version
2.2.11
With the default set of templates to disable ads and having ads without further conditions on post_above_content and thread_view_above_messages XenForo does generate the following template code:

HTML:
<xf:macro name="post_above_content" arg-post="!">
<xf:if is="!in_array($xf.reply.template, ['error', 'login', 'login_password_confirm', 'login_two_step', 'message_page', 'register_complete', 'register_connected_account', 'register_confirm', 'register_form'])">
    <xf:comment>Test 1</xf:comment>
    <b style="color:red">Some advertising content</b>
</xf:if>
</xf:macro>

<xf:macro name="thread_view_above_messages" arg-thread="!">
<xf:if is="!in_array($xf.reply.template, ['error', 'login', 'login_password_confirm', 'login_two_step', 'message_page', 'register_complete', 'register_connected_account', 'register_confirm', 'register_form'])">
    <xf:comment>Test 2</xf:comment>
    <b style="color:red">Some advertising content</b>
</xf:if>
</xf:macro>

This seems pretty inefficient:
  1. The check is done for every single ad position; in case of positions that are called multiple times on a page (like post_above_content) it is also repeated multiple times
  2. Under normal curcumstances, in this example in_array() would never return true anyway
Could this be changed so the check is only done once per page?
 
Last edited:
Top Bottom