XF 2.1 Trying to add a class based on if statements

Matt C.

Well-known member
I'm trying to add a class to the article element in the post_macros template if the post user id equals the visitors user id.

Like this:
Code:
<xf:if is="{$post.User.user_id} == {$xf.visitor.user_id}">
    message--selfPost
</xf:if>

But obviously I can't add an if statement inside an html element.

Can I do it with this format? I'm unfamiliar with it.
HTML:
{{ $isIgnored ? 'is-ignored' : '' }}

Thank you.
 
I found a way, but it's not ideal.

Code:
<xf:if is="{$post.User.user_id} == {$xf.visitor.user_id}">
    <xf:js>
        $( "article[data-author='{$xf.visitor.username}']" ).addClass( "message--selfPost" );
    </xf:js>
</xf:if>
 
Back
Top Bottom