Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

Anyone know how to hide a widget if someone is viewing XFMG (Xenforo media gallery)? I don;t want the widget to show when in the gallery, just the forums.
 
Anyone know how to hide a widget if someone is viewing XFMG (Xenforo media gallery)? I don;t want the widget to show when in the gallery, just the forums.
Unless I misunderstand you'd just uncheck the widget to be in the widget control.

What widget are you trying to hide?
 

Attachments

  • Screen Shot 2024-02-01 at 4.53.33 PM.webp
    Screen Shot 2024-02-01 at 4.53.33 PM.webp
    25.3 KB · Views: 0
You can exclude certain templates by adding them to this code:

!in_array($xf.reply.template, ['xfmg_media_index','templat_X'])

Or you can exclude the whole XFMG section with this coce:

$xf.reply.section != 'xfmg'

(y)
 
@Paul B and others.
Instead of creating a new thread, I thought it's better to ask here.

Is there a Xenforo date/time conditional that I can use only for the d-m php date format?

I need this for a "On This Day" feature, so e.g. on every 31st of May, the conditional would show the content. Similarly for other selected dates that I'd choose to display content.

E.g. on every 04.07 it shows a message for Independence Day
For every 24.12 it shows a message for Xmas eve etc....
 
Last edited:
Found it !

I remembered to have set another setting based on other conditions.
So basically you just need to declare a new variable $OnThisDay that calls the time function with the format you wish; and then just create the simple conditional to check.

Code:
<xf:set var="$OnThisDay" value="{{ date($xf.time, 'd m') }}" />

<xf:if is="$OnThisDay == '30 05'">
    On 30 May this event happened......
</xf:if>

I hope someone finds this useful.
 
Last edited:
Top Bottom