Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

I've got an @AddonsLab filter group with a condition that changes depending on which other filters are selected. I'm trying to target closed_perm so I can make changes only when that filter option is selected (I only want to show businesses which are permanently closed when the filter is selected, otherwise hide).

When only that option is selected it's $__globals.filterSet.link_rms_item_options.0.closed_perm

1589657315722.webp

When other filters are selected it changes, in this case it's $__globals.filterSet.link_rms_item_options.2.closed_perm

1589657136603.webp

Something like this would work, but it's ugly.

Code:
    <xf:if is="$__globals.filterSet.link_rms_item_options.0 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.1 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.2 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.3 == 'closed_perm'">

Is there a cleaner way to do it, maybe with in_array or some other wildcard option I'm not aware of?
 
hi
How can i show something to male only?
Is there a gender conditional statement?
Thank you

You could use a custom field for people to select their gender, then use a condition based on that field. The only issue with this I see is; is the field editable by users? I would assume it has to be for a little while, while you get it implemented for everyone. After that I think it's possible to set the field so it's required to be filled out at registration, but can't be edited by users afterwards.
 
What if they change sex?

That's exactly the problem, with the editable custom field, then they can change it anytime anyway. Could make it a request to staff to change with provided justification, but it's less intuitive. Only other way is a custom addon which allows a limited number of changes.
 
What's the percentage of gender change in your place? If higher than 1%, that could be a problem, otherwise.. you can change it manually for them if they really got such requests.
 
You could use a custom field for people to select their gender, then use a condition based on that field

Hi,
By default in xenforo i have user_field_title.gender. How can i use it?

<xf:if is="{$xf.visitor.user_field_title.gender} == 'female'">
Show content...
</xf:if>
 
Last edited:
hi,
how to get from lightbox_macros variable "pageTitle" ?
i write on lightbox_macros {{ dump(vars()) }} and see pageTitle, but can't display it

1590820864741.png

i need get "pageTitle" or "threadTitle" from lightbox_macros template
as sample - TELEFUNKEN 17MB55
 
I'm trying to add conditionals in the template "message_macros" to display a clickable premium banner to multiple user groups but can't seem to get it working. Here's my code:

Code:
<xf:if is="{{$user && $user.isMemberOf('3,4,6')}}">
    <a href="https://link.com"><img src="/img/supporting-badge1.png" /></a>
</xf:if>
 
I'm trying to add conditionals in the template "message_macros" to display a clickable premium banner to multiple user groups but can't seem to get it working. Here's my code:

Code:
<xf:if is="{{$user && $user.isMemberOf('3,4,6')}}">
    <a href="https://link.com"><img src="/img/supporting-badge1.png" /></a>
</xf:if>

You don't need both conditions there, just the isMember is fine, try:
Code:
<xf:if is="{{$user.isMemberOf('3, 4, 6')}}">
<a href="https://link.com"><img src="/img/supporting-badge1.png" /></a>
</xf:if>
 
I've got an @AddonsLab filter group with a condition that changes depending on which other filters are selected. I'm trying to target closed_perm so I can make changes only when that filter option is selected (I only want to show businesses which are permanently closed when the filter is selected, otherwise hide).

When only that option is selected it's $__globals.filterSet.link_rms_item_options.0.closed_perm

View attachment 225296

When other filters are selected it changes, in this case it's $__globals.filterSet.link_rms_item_options.2.closed_perm

View attachment 225295

Something like this would work, but it's ugly.

Code:
    <xf:if is="$__globals.filterSet.link_rms_item_options.0 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.1 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.2 == 'closed_perm' OR
               $__globals.filterSet.link_rms_item_options.3 == 'closed_perm'">

Is there a cleaner way to do it, maybe with in_array or some other wildcard option I'm not aware of?

Anyone?
 
New Conditionals... :D

Check for Threadowner/Threadstarter
Code:
<xf:if is="{$__globals.thread} AND {$__globals.thread.user_id} == {$user.user_id}">

or

Code:
<xf:if is="{$thread.user_id} == {$xf.visitor.user_id}">
 
Last edited:
How send variable $thread.title from thread_view to bb_code_tag_attach ?

I add to thread_view code
Code:
<xf:macro template="bb_code_tag_attach" name="mymacro" arg-mytitle="{$thread.title}" />

but not have {$mytitle} in bb_code_tag_attach
Where is the mistake ?
How to pass this variable?
 
46. How can I hide content on a specific forum? doesn't work for me. What am I doing wrong? Thanks for your help.

Version: 2.1.10...
 
Do conditional statements work to display content within a specific XFRM category? If so, what what would this be?
 
Top Bottom