Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-12-28 07:44:48

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#2 2010-12-29 08:07:47

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,376
Website GitHub Mastodon Twitter

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

#3 2010-12-29 09:58:53

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#4 2010-12-29 13:49:40

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,376
Website GitHub Mastodon Twitter

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

#5 2010-12-29 18:56:46

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#6 2010-12-29 18:58:14

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#7 2010-12-29 19:50:27

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#8 2010-12-29 20:27:46

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: user agent switcher and act_if_mobile

Ok I am still on 4.2 this makes sense then

Offline

#9 2010-12-30 06:39:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,376
Website GitHub Mastodon Twitter

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

#10 2010-12-30 06:46:36

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#11 2010-12-30 08:18:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,376
Website GitHub Mastodon Twitter

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

#12 2011-01-09 19:32:52

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

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

#13 2011-02-02 17:31:33

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: user agent switcher and act_if_mobile

i still haven’t taken care of this. ping!

Offline

#14 2011-02-03 00:28:06

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

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.


My Plugins

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

Board footer

Powered by FluxBB