Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
user agent switcher and act_if_mobile
i don’t see an official support thread for act_if_mobile, but i’m wondering if anyone is able to get this firefox extension to work with the plugin?
Offline
Re: user agent switcher and act_if_mobile
Hi Elliott,
You can switch user agents in Safari without a plugin. I tested the act_if_mobile on it and it seems that it works as expected.
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: user agent switcher and act_if_mobile
thanks yiannis. I have a problem here because the safari user agent switching works fine. for example going to cnn.com shows a mobile site. but when i go to my own site, these user agents aren’t emulating anything. load it up on my iphone and i’m seeing what act_mobile is trying to do.
also does this code look correct?
<txp:act_if_mobile>
<link rel="stylesheet" href="<txp:css name='iphone' />" type="text/css" media="handheld" />
<txp:else/>
<link rel="stylesheet" href="<txp:css />" type="text/css" media="screen" />
</txp:act_if_mobile>
Offline
Re: user agent switcher and act_if_mobile
Your code seems fine and act_if_mobile seems buggy.
as the else statement is not behaving properly
In the case of a screen user agent the site looks ok but when I chose iphone 4.1 both stylesheets load.
Did you try <txp:else />, with the space after the e?
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: user agent switcher and act_if_mobile
ok i seemed to have ironed this out. the bug in the code was
<txp:css name='iphone' />
which should be
<txp:css n='iphone' />
what doesn’t make sense to me is textbook says it should be name=”“
and i did at that space too around the else for insurance.
Last edited by mrtunes (2010-12-29 18:57:05)
Offline
Re: user agent switcher and act_if_mobile
one more thing: i need to figure out how to add a link that says “view full site”. so it somehow has to override what act_if_mobile is doing. does anyone know how i can do this?
Offline
Re: user agent switcher and act_if_mobile
mrtunes wrote:
what doesn’t make sense to me is textbook says it should be name=”“
It is name. The attribute was changed to name, and the n deprecated, in 4.3.0 release. Just as Textbook’s <txp:css /> page states.
Offline
Re: user agent switcher and act_if_mobile
Ok I am still on 4.2 this makes sense then
Offline
Re: user agent switcher and act_if_mobile
Elliott,
Looking at your site and looks fine now when switching user agents but when I go to ipad it still shows the iphone css. Are you working on a solution for that?
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: user agent switcher and act_if_mobile
Hey thanks for checking it out. I was recently wondering about the iPad so it’s good that you brought this up. I am going to guess that the act plugin redirects iPad as a mobile device? If so I will have to adjust because it’s more of a desktop design, right?
Offline
Re: user agent switcher and act_if_mobile
mrtunes wrote:
Hey thanks for checking it out. I was recently wondering about the iPad so it’s good that you brought this up. I am going to guess that the act plugin redirects iPad as a mobile device?
yes
If so I will have to adjust because it’s more of a desktop design, right?
I would think so.
Maybe a liquid layout might be the answer or using min max widths… not sure
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: user agent switcher and act_if_mobile
does anyone know how i can edit the act_if_mobile plugin so that it doesn’t treat the iPad as one of these mobile sites?
Offline
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