Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

So I have this case where I am not able to combine two statements.

I am currently using this:
<xf:if is="{$__globals.forum.node_id} != 116">

Works fine. But I now also have to restrict the same code segment to non-search pages. The code for which is:
<xf:if is="$template != 'search_form'">

How do I combine these two!

<xf:if is="{$__globals.forum.node_id} != 116 AND $template != 'search_form'}"> does not seem to work. Thanks!
 
i realized that xenforo has a simpler option of hiding ads from search pages. added these to the exclusion (Prevent ads showing in these templates) box:

search_form
search_form_all
search_form_macros
search_form_post
search_form_profile_post
search_result_page
search_result_post
search_result_profile_post
search_result_profile_post_comment
search_result_thread
search_results
tag_search

this seems to have worked. my basic requirement is to not show ads on search result pages. this should be fine right? thanks!
 
Is it possible to display something in thread view only if it is within a specific forum node? <xf:if is="$forum.node_id == x"> doesn't work since thread view isn't a node...
 
<xf:if is="$thread.Node.node_id == x">
or maybe
<xf:if is="$thread.Forum.Node.node_id == x">
and some {} around $thread.bla

Edit: Actually node_id exists for $thread itself.
 
<xf:if is="$thread.Node.node_id == x">
or maybe
<xf:if is="$thread.Forum.Node.node_id == x">
and some {} around $thread.bla

Edit: Actually node_id exists for $thread itself.
<xf:if is="$thread.node_id == x"> did the job. Thank you.

Any idea how to check the current style? Ive tried $currentStyle_id, $style_id, $visitor.style_id
 
Is it possible to use something like this $requestPaths.requestUri in a conditional statement? E.g. show only on URLs containing "xyz".
 
I've seen it asked twice but not answered... is there a way to set up a custom user field, let's call it "Sunshine" and it's a check box, that can be used as a conditional check, so IF the user has "Sunshine" checked in their profile, they get one thing, and if they have it unchecked, they do not?
 
I've seen it asked twice but not answered... is there a way to set up a custom user field, let's call it "Sunshine" and it's a check box, that can be used as a conditional check, so IF the user has "Sunshine" checked in their profile, they get one thing, and if they have it unchecked, they do not?
I guess it can be done with a new group and user group promotion system

Code:
/admin.php?user-group-promotions/
 

Attachments

  • 218F175D-8687-41AB-8CEC-683EB4D7EB62.webp
    218F175D-8687-41AB-8CEC-683EB4D7EB62.webp
    37.1 KB · Views: 30
  • 2CEDB274-654D-4A2A-AF5E-DE40209DB148.webp
    2CEDB274-654D-4A2A-AF5E-DE40209DB148.webp
    55.7 KB · Views: 29
  • 35C0DB39-1034-4DDA-B01B-79ACCF945848.webp
    35C0DB39-1034-4DDA-B01B-79ACCF945848.webp
    51.8 KB · Views: 29
@eTiKeT™
@S Thomas

How to display content only in threads of particular forums ?

For eg, I want to display ADs only in the threads that belong to one of these forums with Node Ids - 4, 6, 8

I tried this, but does not seem to work.

<xf:if is="in_array({$thread.node_id}, [4,6,8])">
 
<xf:if is="in_array({$thread.node_id}, [4,6,8])">
There is no 'thread.node_id'. Use 'forum.node_id'. I already said that in your other post.
See here:
I do not quite understand, but here is an example of concealment in a certain forum and certain forums.
Code:
<xf:if is="{$forum.node_id} != x">
Hide content. . .
</xf:if>

Code:
<xf:if is="in_array(!{$forum.node_id}, [x,y,z])">
Hide content...
</xf:if>
 
XF2: Using conditional statements, how do I identify if a page is a Index page (or) What's New page (or) Search Results page ...etc ?
 
Top Bottom