Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

What is the statement for showing something every 2 or 3 posts?

If I use
Code:
<xf:if is="$post.position % $xf.options.messagesPerPage == 2">
it shows only after the second post, but i want it repeating and I'm struggeling with the right code :)
 
it shows only after the second post, but i want it repeating and I'm struggeling with the right code :)
I never worked with the modulo operator. You can easily get what you want and be more flexible with an array. Something like:

HTML:
<xf:if is="in_array($post.position, [2,5,9,15])">
   Show content...
</xf:if>

Edit: You should be able to use the modulo operator in that way:

HTML:
<xf:if is="$post.position % X == 0">
   Show content...
</xf:if>
-> X is for "every X post"; e.g. 2 for every second post.
 
I never worked with the modulo operator. You can easily get what you want and be more flexible with an array. Something like:

HTML:
<xf:if is="in_array($post.position, [2,5,9,15])">
   Show content...
</xf:if>

Edit: You should be able to use the modulo operator in that way:

HTML:
<xf:if is="$post.position % X == 0">
   Show content...
</xf:if>
-> X is for "every X post"; e.g. 2 for every second post.

Thank you!
 
Hello, i need a clarification about this one

8. How can I show content from x if the user's likes is bigger?
HTML:
<xf:if is="$user.like_count|number > x">
   Show content...
</xf:if>

Is it only the number of likes (thumb-up) or the number of positive reactions (the total reaction score in fact) that is taken into account?
Thanks.
 
Is it only the number of likes (thumb-up) or the number of positive reactions (the total reaction score in fact) that is taken into account?
This list is outdated. In the current XF version, there is no likes_count column in the xf_user table anymore. You should use reaction_score instead (which takes the "score" into account).
 
About this one
HTML:
<xf:if is="$sidebar">
    Content...
</xf:if>
In what case do we use it? I don't quite understand its interest, how it works and in which template this code should be written.
Thanks.
 
In what case do we use it? I don't quite understand its interest, how it works and in which template this code should be written.
the corresponding headline is:
How can I show content on pages with a sidebar?
I never worked with that condition, but it seems that it gives true (no matter where you place it) if the output contains a (right) sidebar in the end.
 
the corresponding headline is:

I never worked with that condition, but it seems that it gives true (no matter where you place it) if the output contains a (right) sidebar in the end.
Is there a condition to check, if a widget is located in the sidebar or on any other position of the page?
 
Is there a way for us to use a conditional like "$xf.visitor.isMemberOf" but for $user?

I tried "$xf.user.isMemberOf" and as expecteded didn't work in accordance to dump vars
 
Trying to use conditional statements within a custom field (in the Value display HTML) so depending on what choice a user names, the link / href is different. Any tips?
 
Top Bottom