Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

eTiKeT™

Active member
#25
#26
Thanks for this resource!
I want modify XFMGallery Slider Media widget to show media uploaded only from users i following ( in my site i call Friends)
What is the statement?
Thanks
Antonio
 

ge66

Active member
#27
There was an old XF1.5-question about an Ad in the last post on a page only if there are more than 2 posts on that page. @Brogan answered it and this should work in XF2.0

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage == $xf.options.messagesPerPage - 1 OR $post.position == $thread.reply_count AND $thread.reply_count % $xf.options.messagesPerPage > 1">
    Ad code here <xf:ad position="post_above_content" arg-post="{$post}" />
</xf:if>
 

Brad Padgett

Well-known member
#29
Just so you know this should be changed.

"17. How can I show content only at home?"

Change:

Code:
<xf:if is="$template != 'forum_list'">
Show content...
</xf:if>
To:

Code:
<xf:if is="$template == 'forum_list'">
Show content...
</xf:if>
I believe you put that there so that users could put something on the forum_list only. The first code does not work for only putting something on the forum_list. The second code does and I have tested it.

Let me know what you think. Thanks
 

OperaManiac

Well-known member
#31
<xf:if is="{$forum.node_id} != x"> does not work under container content above option for me.

also is it possible to show content between the two post blocks instead of inside the post?
 
Last edited:

Dadparvar

Well-known member
#32
It seems this one is missed (or I'm tired and couldn't find it in resource page)
Can see if user has permission:
Code:
<xf:if is="{{ $xf.visitor.hasPermission('Dadparvar_PricingTables', 'Can_See_PricingTable_One') }}">
    User will see this text if s/he has "Can_See_PricingTable_One" permission of "Dadparvar_PricingTables" group.
</xf:if>
 

Brad Padgett

Well-known member
#33
also is it possible to show content between the two post blocks instead of inside the post?
I could never even find out how to do the above quote in Xenforo 1. If anyone know's how to put an ad in between the first and second post without being inside it for Xenforo 2 let me know. That would be nice to know.
 

OperaManiac

Well-known member
#34
it did work fine on xf1. i think this is the conditional post that worked for me:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 1>
in template:
ad_message_below

cannot find anything for xf2. also finding it hard to get the conditional statement work to hide ads in specific forums. even that worked great in xf1 using !in_array({$thread.node_id}, array(nodeid)) this.
 

Brad Padgett

Well-known member
#35
it did work fine on xf1. i think this is the conditional post that worked for me:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 1>
in template:
ad_message_below

cannot find anything for xf2. also finding it hard to get the conditional statement work to hide ads in specific forums. even that worked great in xf1 using !in_array({$thread.node_id}, array(nodeid)) this.
Yeah I'm sure it worked, I just never knew what it was. But I'll keep an eye out for anyone who knows the answer. I'm sure the answer will pop up soon.
 

oloman

Active member
#36
There was an old XF1.5-question about an Ad in the last post on a page only if there are more than 2 posts on that page. @Brogan answered it and this should work in XF2.0

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage == $xf.options.messagesPerPage - 1 OR $post.position == $thread.reply_count AND $thread.reply_count % $xf.options.messagesPerPage > 1">
    Ad code here <xf:ad position="post_above_content" arg-post="{$post}" />
</xf:if>
it does'nt display ads on the last post of the last page if it is not full.
for exemple, if last page has 8 posts only, it won't display ads until the last page reach 20 posts.
 
#38
Can't get this to work. I'd like to hide ads from specific nodes, "Container breadcrumb (bottom): Below" and "Container breadcrumb (top): Above"

Any ideas what i'm doing wrong?

Code:
<xf:if is="!in_array({$forum.node_id}, [1,2,3])">
                  Hide content..
</xf:if>
 
#39
There was an old XF1.5-question about an Ad in the last post on a page only if there are more than 2 posts on that page. @Brogan answered it and this should work in XF2.0

Code:
<xf:if is="$post.position % $xf.options.messagesPerPage == $xf.options.messagesPerPage - 1 OR $post.position == $thread.reply_count AND $thread.reply_count % $xf.options.messagesPerPage > 1">
    Ad code here <xf:ad position="post_above_content" arg-post="{$post}" />
</xf:if>
This goes in forum_list template right? Sorry just trying to make sure I put things in the right place.
 
Top