XF 2.0 xf:if condition not working properly

uf4b

New member
Hello,
I need to add some advertisements only below the first post message in thread view.

I added a counter variable in the thread view template and passed it as argument to the post macros template:


PHP:
        <xf:set var="$index" value="1" />

        <div class="block-body js-replyNewMessageContainer">
            <xf:foreach loop="$posts" value="$post" i="$index">
                <xf:if is="$post.message_state == 'deleted'">
                    <xf:macro template="post_macros" name="post_deleted"
                        arg-post="{$post}"
                        arg-thread="{$thread}" />
                <xf:else />
                    <xf:macro template="post_macros" name="post"
                        arg-post="{$post}"
                        arg-thread="{$thread}"
                        arg-index="{$index}" />
                </xf:if>
            </xf:foreach>

In post_macros template I check the counter but the condition is always true ..

PHP:
<xf:macro name="post" arg-post="!" arg-thread="!" arg-index="!">
    <article>
    ....
    </article>
    
    <xen:if is="$index == 1">
        // do adv
    </xen:if>
</xf:macro>


What's wrong ?
Thanks in advance
 
Back
Top Bottom