Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: adi_mobile - Mobile browser detection
Does <txp:adi_mobile_script /> call another script?
Or does it execute jquery?
I’m trying to calculate the server load overhead using this will have.
Last edited by geoff777 (2012-01-18 21:10:24)
There are 10 types of people in the world: those who understand binary, and those who don’t.
Offline
#32 2012-01-18 21:13:52
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_mobile - Mobile browser detection
It’s a small amount of Javascript, which is designed to run only when the orientation changes.
Offline
#33 2012-02-06 01:39:16
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_mobile - Mobile browser detection
Version 0.2 available for download.
- upgraded Mobile_Detect class (now detects Android Tablet/Blackberry Tablet/Windows Phone)
- improved tablet detection functionality
- new adi_mobile attribute ‘useragent’
- new adi_mobile attribute ‘include’
See the plugin help for tablet examples.
Offline
#34 2012-02-06 11:14:42
- gfdesign
- Member

- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: adi_mobile - Mobile browser detection
Thanks Adi for your nuisance.
Saludos desde Argentina
Last edited by gfdesign (2012-02-06 11:14:57)
Offline
Re: adi_mobile - Mobile browser detection
Adi,
Thank you much for this excellent plugin. I used it for the first time last week – enabling different menus to show up for iPad & mobile users (some drop down menus that work fine on desktop/laptop machines didn’t work well on touch devices). Your plugin works beautifully.
Keith
Offline
#36 2012-03-07 15:19:44
- hallstu
- Member
- From: UK
- Registered: 2006-04-18
- Posts: 16
Re: adi_mobile - Mobile browser detection
hallstu wrote:
bq. So when you connect to your website using the Android HTC Desire HD, it’s telling us it’s a Mac running Snow Leopard? Do what?
Hi Adi, sorry I completely forgot to reply to this – but just in case you’re interested, turns out HTC (not Android) spoof the user agent by default to appear as a mac, but you can switch this off in the phone settings. No idea why they do this but your plugin works great now.
Thanks again
Offline
#37 2012-03-07 20:32:24
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_mobile - Mobile browser detection
hallstu wrote:
Hi Adi, sorry I completely forgot to reply to this – but just in case you’re interested, turns out HTC (not Android) spoof the user agent by default to appear as a mac, but you can switch this off in the phone settings. No idea why they do this but your plugin works great now.
Phew! Thanks fror letting me know.
Offline
Re: adi_mobile - Mobile browser detection
Hi Adi,
Not sure if I’m using your plugin correctly – I placed <txp:adi_mobile /> at the top of my page template (first above anything else and then later before the ending </head> tag just to test both options). Then in the page:
<txp:adi_if_mobile>
<txp:article limit="10">
<txp:else />
<txp:article limit="30">
</txp:adi_if_mobile>
That returns a big blank i.e no articles are returned at all and debugging says nothing. The purpose is simply to return fewer articles on mobile, not sure what I’m missing?
Edit: Now I realise what the error is. Pain!
Last edited by jstubbs (2013-02-16 10:54:32)
Offline
Re: adi_mobile - Mobile browser detection
Is there any way this marvellous plugin could be coerced into detecting retina displays, maybe making some txp:variable available so we can decide server-side whether to serve images at standard res or @2x? The only reliable way seems to be from javascript:
var retina = window.devicePixelRatio && window.devicePixelRatio >= 2;
Even if that could be checked on first visit and a cookie set, which could manifest itself as a txp:var on second page view, it’d be better than nothing.
At least then only the first page would be in standard res on such devices and a refresh or jump to another page would allow me to use something like smd_thumbnail to deliver the right image size to the right devices, without having to download both sets to mobiles, or to upload all images at double res and scale them back to 50% with a media query.
Any Adi magic beans available for this challenge?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#40 2013-10-16 10:04:55
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_mobile - Mobile browser detection
Bloke wrote:
Any Adi magic beans available for this challenge?
Hi Stef. Shouldn’t be a problem … Just recovering from a trip to the Old Country … I’ll look into it when I find some magic coffee beans.
Offline
Re: adi_mobile - Mobile browser detection
Hi,
I have this problem
Anyone? Thx!
Edit: Seems to be fix. I forgot the <txp:adi_mobile /> tag before to use <txp:adi_if_mobile>!
Last edited by NicolasGraph (2013-11-14 12:02:59)
Offline
Re: adi_mobile - Mobile browser detection
Hi adi,
I’d like to use your plugin to detect android devices and serve them different code for the videos on a recently launched site. Would the code below work?
<txp:adi_if_mobile>
<txp:adi_if_mobile type="android">
<iframe src="https://player.vimeo.com/video/<txp:link_description escape="" />?color=ba0000&title=0&byline=0&portrait=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<txp:else />
<iframe src="https://player.vimeo.com/video/<txp:link_description escape="" />?title=0&byline=0&portrait=0" allowfullscreen></iframe>
</txp:adi_if_mobile>
</txp:adi_if_mobile>
ps. The reason I am serving different content is that I want to be serving valid html whenever possible.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#43 2015-05-07 22:25:21
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_mobile - Mobile browser detection
Hi Yiannis … yes, that looks good to me.
Offline
Re: adi_mobile - Mobile browser detection
Thanks!
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: adi_mobile - Mobile browser detection
In this article I’m using adi_mobile with smd_thumbnail and smd_macros to render a small image if the viewport is 640px or less and a larger one if the viewport is larger than 640px:
<txp:adi_mobile />
<txp:adi_if_mobile width="640">
<txp:smd_thumbnail id="{img_id}" type="small" />
<txp:else />
<txp:smd_thumbnail id="{img_id}" type="{style}" />
</txp:adi_if_mobile>
with this tag in the article:
<txp:smdadi id="182" type="landscapemedium"/>
The outcome is that the smaller one is rendered (look with your smartphone); the larger one is not. I guess the if/else construction isn’t right … :|
Can anybody help me with this one, please?
[edit]
It looks like the “landscapemedium” is rendered if the viewport is 640 or less … !? What am I missing here?
Last edited by RedFox (2016-02-03 09:06:08)
Offline