XF 2.2 Conditional statements : user & visitor

Nicolas FR

Well-known member
Hello,
How would you define the difference between these 2 conditions?

HTML:
<xf:if is="$xf.visitor.message_count|number > 10">
    Content
</xf:if>
HTML:
<xf:if is="$user.message_count|number > 10">
    Content
</xf:if>

Thanks.
 
$visitor is the current logged in user, $user is the record being processed/viewed.

For example, if I browse to your profile page, I am $visitor and you are $user .
 
Both conditionals are IMHO nonsense, you don't want to compare a formatted int with an int as that would give unexpected results, as for example '1.000' > 10 is false ('1.000' is 1000 formated with . as thousand separator).

So what you really want is
Code:
<xf:if is="$xf.visitor.message_count > 10">

The first version will work everywhere and check if the viewer has more than 10 messages, the second one will only work where $user is defined and check if that user (whoever that is) has more than 10 messages.
 
Top Bottom