Account
 
 
 
0
 
 
21 Jun

Free: Mobile detection plug-infor identification of mobile devices in Joomla!

Today we have yet another free Joomla! plug-in for all Joomla users (Joomla! 2.5, 3.x and higher) for you, under the self-explanatory name "yagendoo Joomla! Mobile Detection".

The plug-in has a really simple design and helps users and developers find out, in their code, whether the device that the website is being visited on is a mobile device, such as a mobile phone or tablet PC, or not.

In addition, lots of other information, such as the operating system, user agent or exact type of mobile device, can also be checked and/or used.

Particularly in terms of "responsive web design", you will have some real tricks up your sleeve with "yagendoo Joomla! Mobile Detection" – keen users and developers will know what we mean and know how to use it. ;-)

There is already a function in Joomla! that allows you to do this, but due to the complexity, Joomla! itself does not do this reliably enough, which is, of course, more or less the nature of the beast as the number of different mobile devices and operating systems is growing rapidly.

Download

You can download the latest version of the plug-in here.

Download plug-in  

Licence

The plug-in is available free of charge for individuals and companies and is published at GNU/GPLv3. You may use the plug-in for your own sites, use it on other websites or create your own plug-in based on it and distribute it. All copyrights in the code must remain intact.

Available functions

The following functions are available in "yagendoo Joomla! Mobile Detection".

MobileDetector::isMobile();

MobileDetector::getUserAgent();

MobileDetector::getPhoneDevices();

MobileDetector::getTabletDevices();

MobileDetector::isTablet($userAgent = null, $httpHeaders = null);

MobileDetector::is($key, $userAgent = null, $httpHeaders = null);

MobileDetector::getOperatingSystems();

Credits

The plug-in is based on the (MIT) code library of Serban Ghita, which is also available free of charge and forms the core of the plug-in. Thank you for your great work, Serban!

We wish you all lots of fun with the plug-in. If you like the plug-in you can support the original developer here.

Posted by YannickS on in News
Rate this blog entry:
10
34 Comments  
 
 

Comments

  • Robert Went Tuesday, 25 June 2013

    Great stuff :)

    I was about to build this into my template but I guess now there is no need.
    Are there any limitations on usage? Ie. can I use it in the main index file of a template and in any override?

    Thanks for your work on this!

     
  • YannickS Wednesday, 03 July 2013

    Hey Robert,

    there is no limitation. You can use it wherever you need it!

    Kind regards,
    Yannick

     
  • Robert Went Wednesday, 03 July 2013 1 person likes this comment.

    Perfect! I think I might build a few options for it into my new template:)

     
  • nick Thursday, 29 August 2013

    I've got the plugin installed and working, but am having trouble understanding how to use the MobileDetector::isMobile(); function.

    For example, I want to detect if it's a mobile/tablet device and redirect to a sub-domain.

    Could you provide any examples of using the functions?

    Thanks!

     
  • SimonS Monday, 02 September 2013

    Hello Nick,

    the "isMobile" methods returns true if a mobile device is detected, so in your case an example code would look like:
    if(MobileDetector::isMobile() === true)
    {
    // mobile device detected do redirect
    header('Location: http://some.subdomain.com', true, 301);
    exit;
    }

     
  • Ian Wensink Monday, 09 September 2013

    Hello,

    This plugin looks like the one I need, but I really have no idea of how to use it. I clicked 'download plug-in' which gave me a zip with a php script. What should I do now? Where do I have to put the file or the code? And can you explain step by step how to use the plugin? So what do I have to do so the visiter gets to an other page like the question above. I'm not very expert in php, so if you could explain everything it would be very handy.

    Thanks in advantage,
    Ian Wensink

     
  • YannickS Monday, 09 September 2013

    Hello Ian,

    just install it via the Joomla installer. But if you want use it, it´s required to have some PHP-skills. It´s mainly developed for other developers.

    Currently we can´t provide a step-by-step guide, because of lack of time. I am sorry!!

    Kind regards,
    Yannick

     
  • Sammy Thursday, 17 October 2013

    Hi Yannick,

    I want once it detects mobile device, to redirect to a sub domain. I've read the comments here and I have one question.

    Where do I place this code?

    if(MobileDetector::isMobile() === true)
    {
    // mobile device detected do redirect
    header('Location: http://some.subdomain.com', true, 301);
    exit;
    }

    On the root index page or on the template index page?

    Kind regards,

    Sammy

     
  • YannickS Thursday, 17 October 2013

    Hey Sammy,

    if you place it in the root index file, it is a hack what maybe will overrided by a Joomla update. I think you should put it in your template index, if you only use one template.

    Best regards,
    Yannick

     
  • Boldee Wednesday, 23 October 2013

    I originally used the php mobile detect code directly in my index.php this plugin is a real time saver thank-you for that.

    I have a question however, is there a way to override mobile detection so that users have an option to view the desktop version of the site from the mobile device via a redirect?

     
  • YannickS Friday, 25 October 2013

    Hello Boldee,

    currently not - I am sorry, but we work on something like that. Sorry to say, that I can´t give you a timeframe for now.

    Kind regards
    Yannick

     
  • Boldee Friday, 25 October 2013

    Hi YannickS
    Thanks for the reply.

    If you can get a function working in the future for redirection that would a be great asset for this plugin.

    I did a little research after posting here about whether my website users actually want to be forced to use a mobile site or have a choice of desktop or mobile and it was a split 50 50, so I have decided to take a different approach, I am however still using this great plugin all be it slightly different to how I originally intended :)

     
  • Rob Friday, 25 October 2013

    I think you would have to set a cookie and then check for it before redirecting.

    Then you can direct to the mobile if nothing is set and if they choose desktop set a cookie which would be picked up the next time the page is loaded and then not redirect.

     
  • F Monday, 17 March 2014

    Hello Rob,

    I find your advice helpfull. I'm trying different approaches on preventing further redirection with cookies the whole day and non of them worked. I get always redirected. Could you please provide an example?

    Here is what I'm trying in Joomla:

    if(MobileDetector::isMobile() === true && isset($_COOKIE['mobile']))
    {
    // problem is here:
    MobileDetector::isMobile() === false;
    // tried even: return false; | $detect = "false";
    // none working
    }
    elseif(MobileDetector::isMobile() === true)
    {
    header('Location: http://m.site.com', true, 301);
    exit;
    }

    And in the mobile site:

    setcookie("mobile","m", time()+3600, "/");

    //----------------------------------------------

    I followed this example (http://stackoverflow.com/questions/5844966/view-full-site-mobile-site-option) as well, but it won't work directly with the yagendoo Joomla plugin:

    isMobile() && isset($_COOKIE['mobile']))
    {
    $detect = "false";
    }
    elseif ($detect->isMobile())
    {
    header("Location:http://www.yourmobiledirectory.com");
    }
    ?>

    Thank you!

     
  • Nick N Monday, 30 December 2013

    Neither one of these actually works. I have a Galaxy S4 and neither one shows information when echoing these below. User agent works and detecting if mobile works but not these.

    MobileDetector::getPhoneDevices();

    MobileDetector::getTabletDevices();

     
  • Dragma Sunday, 09 March 2014

    Hi! thanks for this incredibly useful plugin. I have a problem, I wonder if you can help.
    I did an if/else to hide a particular module when loading on mobile devices, but it still loads it. Here is the code simplified:
    countModules('login')) : ?>













    Thank you,

     
  • Michael Monday, 10 March 2014

    First of all, thank you for this handy plugin!

    When i activate Joomla cache, it doesn't work as expected, though. I use the plugin in order do distinguish between desktop and mobile navigation. When i browse the site simultaneously on a desktop and a mobile browser i often get the wrong site elements with cache turned on.

    Did anybody encounter the same problems yet and is there a solution?

    Thanks

     
  • Michael Thursday, 13 March 2014

    FYI: we managed to bypass the problem by using a thirdparty cache extension.

     
  • Filip Wednesday, 19 March 2014

    Hello,
    Can anyone provide an example of "View full site" redirection with cookie?
    I try to avoid loop redirections to the site's mobile version.
    I tried something like this, but it always ends with loading the mobile site:
    if(MobileDetector::isMobile() === true && isset($_COOKIE['mobile']))
    {
    return false;
    } else {
    header('Location: http://m.site.com', true, 301);
    exit;
    }

    ... and on the mobile landing page:
    setcookie("mobile","m", time()+3600, "/");

    Thanks!

     
  • Guest! Sunday, 13 April 2014 1 person likes this comment.

    404 not found on download link!

     
  • YannickS Tuesday, 15 April 2014

    Thanks for the information - download link is fixed!

     
  • Nik Tuesday, 19 August 2014

    Hi!!

    The plugin works perfect! But I want to know if there is a way to check if the user is on an iPhone?
    Maybe something like this?: $phone = MobileDetector::getPhoneDevices();
    if($phone == "iPhone")
    do something...

     
  • Jonathan Roza Monday, 20 October 2014

    Hi.

    First, I would like to tell that it seems to be a very promising plugin (didn't use it yet).
    My question is: Can I "load a module if it is mobile", or "not load a module if it is mobile"?

    Like:
    MobileDetector::isMobile();
    or
    MobileDetector::isNOTMobile();

    (forgive me the IsNOTMobile, but I don't know the proper command to detect a "not mobile browser". Maybe it's something like !isMobile?).

    Thank's!

     
  • Guy Monday, 27 October 2014

    I need some help! I'm trying to use this plugin in Joomla-virtuemart on a default_products.php page that gets displayed in an html template, without success.

    I originally tried Serbanghita's plugin without luck and them tried this Joomla plugin.

    I'm assuming I don't need to call the plugin up on any page, once it's installed and actiavted?

    I'm trying to use the output to create a conditional callup - and it's not working:

    // Show Products ?>
    isMobile() && !$detect->isTablet() ) { ?>





    The end result is, whatever appears above that conditional segment appears live but without any formatting, and whatever should appear from that conditional segment onwards doesn't get displayed at all. What am I doing wrong?

     
  • TobiasR Monday, 27 October 2014

    Hi,

    once the plugin is installed you should be able to call it using this code:

    if(MobileDetector::isMobile() === true)
    {
    // do something
    }

    Kind regards,
    Tobias

     
  • IanE Wednesday, 18 March 2015

    I thought I had this working perfectly but it detects Chrome on a desktop as mobile, all other browsers I've tried (desktop and Android) work ok, any thoughts as to why this should be? I've tried on a completely different machine and it's exactly the same, use Chrome (Version 41.0.2272.89 m) from a desktop and the plugin thinks I'm mobile.

    Thanks,

    Ian

     
  • IanE Wednesday, 18 March 2015

    Ignore my earlier post regarding Chrome (unless you've come here with the same problem) I downloaded the plugin again and it's working fine now so I guess there must have been an update.

    Thanks for a really useful solution.

    Ian

     
  • Alex Wednesday, 08 April 2015

    Hi, how do I script the code to see if a device is using the android stock browser?

     
  • Alex Wednesday, 08 April 2015

    Hi, how do I script a query to see if the browser is the Android stock browser?

     
  • Alex Saturday, 11 April 2015

    Hi, how do I write the query to detect if a browser is the Android Stock browser?

     
  • Alex Monday, 13 April 2015

    ...is there also a way of identifying the Chrome browser on Android devices?

     
  • Ross Friday, 11 September 2015

    Hi there!
    How can I find if visitor is using the tablet? Because there is no function or method "MobileDetector::isTablet();". And how can I find what OS is using by visitor? I need to know if it's iOS. Can You show some examples or link to documentation? Thank You!

     
  • stuart Wednesday, 21 October 2015

    how can hidde modules?

     
  • Madhvee Tuesday, 05 January 2016

    With reference to the following post:

    Michael Thursday, 13 March 2014
    FYI: we managed to bypass the problem by using a thirdparty cache extension.

    Can you please provide more details?
    I have same issue - plugin does not work when cache is on.

    Madhvee

     

Guest  Saturday, 03 December 2016

 

Looking for a developer?

We´re on your side if you run in problems or we create you whole new websites and onlineshops!

Yagendoo Media Team

Get a quote!

» Portfolio «