Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: user agent switcher and act_if_mobile
i still haven’t taken care of this. ping!
Offline
Re: user agent switcher and act_if_mobile
It looks like the code to detect devices was written by Andy Moore. I don’t think the license of the current version, which does support iPad, is compatible with Textpattern. I’d suggest visiting his site and implementing his code if your use fits his license.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
#15 2011-02-24 02:48:21
- kevinpotts
- Member
- From: Ghost Coast
- Registered: 2004-12-07
- Posts: 370
Re: user agent switcher and act_if_mobile
I am not sure if this can be wrapped into the plugin or not, but I wrote this quick bit for myself to overcome this issue:
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/ipad/i',$user_agent)) {
echo "ipad";
} else echo "not an ipad";
?>
This doesn’t work with nested TXP tags, but it works well for serving up static files like CSS and JS.
Apple’s user-agent for this thing is actually kind of annoying, but I’ve tested the above script and it works well enough.
Update: It looks like Andy Moore’s script uses very similar logic. We used the same matching text, so it must work well enough.
Last edited by kevinpotts (2011-02-24 02:57:45)
Kevin
(graphicpush)
Offline
Re: user agent switcher and act_if_mobile
i will give this a shot thanks. after this experiment, i am looking into using less framework to deal with mobile sites a little better.
Offline
#17 2011-03-22 00:23:39
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: user agent switcher and act_if_mobile
adi_mobile may be of assistance …
Offline