Chris89 Posted August 25, 2020 Posted August 25, 2020 I know there's a way to do this, because I distinctly remember seeing a method named something like IsMobile in one of the files while I was creating my site integration several months back. But I can't for the life of me remember where I saw it and I can't find it anywhere now having checked in the places you'd expect, such as Sessions, Members and Request. Does anyone know where the code for this is so I can look at it?
Solution bfarber Posted August 25, 2020 Solution Posted August 25, 2020 There's no way to do this in PHP with stock code. Your options are 1. You can reference \IPS\Session::i()->userAgent and based on the browser or platform property, determine yourself if you consider it a mobile request. 2. You can use javascript and check ips.utils.responsive.currentIs('phone') which is determined based on responsive breakpoints rather than the platform. Chris89 1
Chris89 Posted August 25, 2020 Author Posted August 25, 2020 Thanks for this. I'm not sure where I thought I'd seen that method then, but I genuinely could have sworn it was in IPS.
Management Matt Posted August 26, 2020 Management Posted August 26, 2020 Way back in the 3.x series, we did have inbuilt methods in PHP to detect a mobile device, so we could show a different theme. In 4, we removed that and created a responsive theme that resizes automatically.
Chris89 Posted August 26, 2020 Author Posted August 26, 2020 Hmm thanks. Must have been that which I looked at then, but I genuinely thought it was 4.x. For those who are interested I managed to solve my problem by just using this simple class here, which does all of the work for you: Mobile Detect - lightweight PHP class for detecting mobile devices (including tablets
Recommended Posts