garethtdavies / detect-mobile

Lightweight PHP plugin for EE2/EE5 that detects a mobile browser using the PHP Detect Mobile class

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Couldn't get this to work in an empty template

liamcrean opened this issue · comments

Can you check current release?

Running EE2.5.5

Ta, Liam

Hi Liam, can you show me what is in your template? Tested on 2.5.5

{if 'exp:detect_mobile:ismobile'} I am a mobile device {else} I am not a mobile device {/if}


This is what I have... I'm using the "mobile detect" plugin at the mo - you think there could be a conflict?

I've tweaked that, but I still get the wrong message...

{if "exp:detect_mobile:ismobile"} I am a mobile device {if:else} I am not a mobile device {/if}

Which gives me "I am a mobile device" on a laptop...

Hi Liam - you need the curly braces around the plugin. This is my error on the readme. I'll get that updated now.

{if "{exp:detect_mobile:ismobile}"}

Ah yeah - the docs are missing a lot of the native mark-up - I'd run a quick test on your code there.

This works great:

{if "{exp:detect_mobile:ismobile}"}
{if '{exp:detect_mobile:type}' == "tablet"}tablet {/if}
{if '{exp:detect_mobile:type}' == "phone"}phone {/if}
{if:else}desktop{/if}

Perfect for a class addition to body template... :)

Great, thanks. Yes will definitely take another look at improving the docs very shortly, thanks for the heads-up.