Resource icon

Browser Detection 2.3.1

No permission to download
'Sorry if this seems like a dumb question, but I have this AddOn installed and don't know why I installed it or if I need it.

I'm now on XF 2.3 and it's working fine but what are the consequences of disabling the AddOn?
 
This add-on is used by ElasticSearch Essentials, which will have an XF2.3 compatible version out this week.

Otherwise disabling it shouldn't break anything
Thank you for the response. That explains why I have it installed. Also, thanks for letting me know that ES Essentials is coming out this week. It's the last AddOn I'm waiting to upgrade.
 
Help me!
How do I make a negation?I don’t want to show the widget for mobile devices.I am using the following construction:

!$xf.mobileDetect
or
!($xf.mobileDetect && $xf.mobileDetect.isMobile())

But it’s not working...
I can't use else in the widget display condition.


The goal is that I don’t want to display the widget on mobile devices.
How should I write the condition?
Thank you!
 
!($xf.mobileDetect && $xf.mobileDetect.isMobile()) should work

I'm not 100% sure it is being injected reliably into the widget display condition. Can you give some context on how that condition is being used?
 
!($xf.mobileDetect && $xf.mobileDetect.isMobile()) should work

I'm not 100% sure it is being injected reliably into the widget display condition. Can you give some context on how that condition is being used?


For example, I want there to be no widgets in the mobile version, like the statistics widget.

I go here
/admin.php?widgets


and use a condition:

1744548626806.webp

It doesn’t work. What’s the mistake?
 
It doesn’t work. What’s the mistake?
You need the $xf.mobileDetect bit mentioned by Xon and (&&) your condition.

Try:
Code:
$xf.mobileDetect && !$xf.mobileDetect.isMobile()
As the Display condition. So on a mobile device that becomes true and false which is false. On a desktop that becomes true and true which is true. So your widget should show on desktop devices.
 
Last edited:
Not having the $xf.mobileDetect && bit means it will error if the add-on is updated or gets into a zombie state.

You can put $xf.mobileDetect in there and use that to check if the value is being injected by depending on if the widget shows up at all. I've test it and it should work.
 
Hi - how about the opposite.

I don't want a widget to show on desktop but I do on mobile. How would I change the above?

Thanks!
 
You can narrow down the problem by trying just $xf.mobileDetect which should evaluate to true if everything is working okay - and so you should see your widget. If that's the case and it is working (step one!), then it must be that the mobile platform is not being detected as a mobile system for whatever reason (since $xf.mobileDetect.isMobile() must be returning as false for it not to show on your mobile), at that point it's hard to know why that is the case.
 
  • Like
Reactions: Xon
Thanks. I think it may be a syntax issue.

I want the widget to:
  1. Only show to visitors; and
  2. Only show on mobile.
I was first checking for visitor then using the "AND" to include the above. This isn't working.
 
Don't use AND or OR, they don't behave the same as && and || (it is a precedence thing), and when in doubt wrap things in ( ).

But using php-style boolean algebra is outside the topic of this thread
 
Back
Top Bottom