Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2011-03-31 18:26:03

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 590
Website

Re: adi_mobile - Mobile browser detection

<img src="/slir/w282/<txp:image_url/>" alt='<txp:image_info type="alt"/>' />

That’s from a site where I’m using it now.

Offline

#14 2011-03-31 19:59:33

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: adi_mobile - Mobile browser detection

Well, it’s all working fine and SLIR has more options than smd_thumbnail and Joe Lencioni seems very helpful on the forum, so it looks a good partner for adi_mobile :-) I found this which has a way to get nice URLs for the images and wondered if it was necessary or desirable?


BB6 Band My band
Gud One My blog

Offline

#15 2011-03-31 20:46:18

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 590
Website

Re: adi_mobile - Mobile browser detection

Looks like the fancy URLs make the code a bit more readable, maybe even easier to remember.

I don’t understand what the point of specifying both parameters like 100×100/1:1 would be though… :-/

Offline

#16 2011-03-31 21:25:41

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: adi_mobile - Mobile browser detection

I’ve never seen urls like the SLIR ones before, but they’re easy enough to understand, so I think I’ll stick with them. You can’t really live without smd plugins though – smd_thumbnail is easier to use if wanting to replace resized images with higher quality images ones. A site I’m working on doesn’t need such high quality so I’ll use SLIR. I also need smd_if because I wanted to cater for 4 viewpoint widths and adi_mobile just has ‘narrow’ and ‘wide’ settings, so the inbetween bit has to be split into 2. Much too daunting for my brain, but Adi very kindly showed me how to do it with smd_if. Someone might find it useful and it brings this thread back on topic, so here it is:

EDIT: I removed the <txp:image_info type="h" /> (and “w”) because I just realised it brings the size of the original image. So now I’m wondering how to use SLIR and put the sizes in when I don’t know them, as pictures have varying widths and heights.

<txp:images break="">
  <txp:adi_if_mobile width="narrow">
    <img src="/slir/w320-q100/<txp:image_url/>" alt="<txp:image_info type="alt"/>" />

<txp:else />

  <txp:adi_if_mobile width="wide">
    <img src="/slir/w480-q100/<txp:image_url/>" alt="<txp:image_info type="alt"/>" />

<txp:else />

  <txp:smd_if field="txpvar:adi_mobile_width" operator="lt" value="768">
    <img src="/slir/w360-q100/<txp:image_url/>" alt="<txp:image_info type="alt"/>" />

<txp:else />

    <img src="/slir/w480-q100/<txp:image_url/>" alt="<txp:image_info type="alt"/>" />

       </txp:smd_if>
    </txp:adi_if_mobile>
  </txp:adi_if_mobile>
</txp:images>

Last edited by zero (2011-03-31 21:44:37)


BB6 Band My band
Gud One My blog

Offline

#17 2011-10-27 20:09:14

hallstu
Member
From: UK
Registered: 2006-04-18
Posts: 16

Re: adi_mobile - Mobile browser detection

Hi, I’ve asked this question a couple of times but keep asking in the wrong place…

Basically I can’t seem to get this plugin to work (or, in fact, pro_mobile or act_if_mobile) on an Android phone or an iPad. Since they are my only mobile devices I’m assuming the code I’ve used isn’t working. Of course it’s more than likely I just haven’t implemented correctly, but the ‘mobiletest’ demo on the website also shows the ‘You’re not a mobile’ message as well. When viewed on an iPhone it displays as I’d expect and states the viewport etc.

Anyone know of any issues with mobile detection with Android or iPads? Seems odd none of the plugins I’ve tried, or the demos, work.

Thanks again…

Offline

#18 2011-10-27 20:32:06

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_mobile - Mobile browser detection

Hi Stu,

adi_mobile should pick up Android devices – at least it does when I test it using an Android emulator. WRT to iPads, adi_mobile determines that they’re not mobiles deliberately – because they have big screens & can display normal websites properly. You have to target iPads explicitly if you want to deliver different content for them.

Try using <txp:adi_mobile debug="1" /> and send me the output.

Offline

#19 2011-10-27 21:39:23

hallstu
Member
From: UK
Registered: 2006-04-18
Posts: 16

Re: adi_mobile - Mobile browser detection

Hi Adi thanks for the quick response.

Yeah I thought that may be the case with the iPad; I should have clarified that I targeted it using <txp:adi_if_mobile type="ipad">, though that may not be the correct way.

The output from the debug code is below.

Firefox Windows 7:

USER AGENT

Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

ADI_MOBILE GLOBALS

array (

‘isMobile’ => false, ‘isAndroid’ => false, ‘isBlackberry’ => false, ‘isOpera’ => false, ‘isPalm’ => false, ‘isWindows’ => false, ‘isGeneric’ => false, ‘isIphone’ => false, ‘isIpad’ => false, )

—————————

Safari iPad:

USER AGENT

Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3

ADI_MOBILE GLOBALS

array (

‘isMobile’ => false, ‘isAndroid’ => false, ‘isBlackberry’ => false, ‘isOpera’ => false, ‘isPalm’ => false, ‘isWindows’ => false, ‘isGeneric’ => false, ‘isIphone’ => false, ‘isIpad’ => true, )

—————————

Android HTC Desire HD:

USER AGENT

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16

ADI_MOBILE GLOBALS

array (

‘isMobile’ => false, ‘isAndroid’ => false, ‘isBlackberry’ => false, ‘isOpera’ => false, ‘isPalm’ => false, ‘isWindows’ => false, ‘isGeneric’ => false, ‘isIphone’ => false, ‘isIpad’ => false, )

So it looks like the iPad is being recognised, just the code isn’t being delivered (though that could be my implementation), but Android not being recognised at all. I also tried <txp:adi_if_mobile type="android">.

Thanks

Offline

#20 2011-10-27 22:02:16

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_mobile - Mobile browser detection

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?

WRT targetting the iPad it’s an issue I’ve come across recently. I’ll get you a beta to try.

Offline

#21 2011-10-28 09:21:50

hallstu
Member
From: UK
Registered: 2006-04-18
Posts: 16

Re: adi_mobile - Mobile browser detection

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?

Yup, seems that way. I don’t understand either, I just browse to the thing! I’ll check some Android forums, seems too weird.

Thanks

Offline

#22 2011-12-26 16:26:04

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: adi_mobile - Mobile browser detection

Hi Adi
First of all, congratulations for this fantastic plugin. I want to start to use it. My doubt is the next:
Testing & Diagnostics Tags don´t work in my sites as in your test page. What do I do wrong ? I must include jQuery in my <head> section ?
Thanks
Fernando

Offline

#23 2011-12-28 20:59:30

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_mobile - Mobile browser detection

gfdesign wrote:

I must include jQuery in my <head> section ?

Hi Fernando. jQuery is only required for viewport dimension/orientation detection. For basic mobile detection – make sure that you’ve got <txp:adi_mobile /> at the top of your page template. You can use <txp:variable name="adi_mobile_useragent" /> to see what it picks up. The <txp:adi_if_mobile /> conditional will then function based on that.

Offline

#24 2011-12-28 21:28:43

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: adi_mobile - Mobile browser detection

Thanks Adi
Please, check my template if I´m doing some wrong

<txp:adi_mobile />
<html>
<head><title>Test Movil</title></head>
<body>
<txp:variable name="adi_mobile_useragent" /> <!-- does work -->
<br />
<txp:variable name="adi_mobile_viewport" />  <!-- doesn´t work, It gives me: ?,?,? -->
<br />
<txp:variable name="adi_mobile_orientation" />  <!-- doesn´t work, It gives me: ? (0) -->
</body>
</html>

Offline

Board footer

Powered by FluxBB